Reduce allocations (#17584)

* Reduce allocations

* Add stringsHasPrefixFold which can compare string prefixes, while ignoring case and not allocating.
* Reuse all msgp.Readers
* Reuse metadata buffers when not reading data.

* Make type safe. Make buffer 4K instead of 8.

* Unslice
This commit is contained in:
Klaus Post
2023-07-06 16:02:08 -07:00
committed by GitHub
parent 1bf23374a3
commit ff5988f4e0
21 changed files with 67 additions and 36 deletions

View File

@@ -268,7 +268,7 @@ func (args eventArgs) ToEvent(escape bool) event.Event {
newEvent.S3.Object.ContentType = args.Object.ContentType
newEvent.S3.Object.UserMetadata = make(map[string]string, len(args.Object.UserDefined))
for k, v := range args.Object.UserDefined {
if strings.HasPrefix(strings.ToLower(k), ReservedMetadataPrefixLower) {
if stringsHasPrefixFold(strings.ToLower(k), ReservedMetadataPrefixLower) {
continue
}
newEvent.S3.Object.UserMetadata[k] = v