File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -568,8 +568,13 @@ func (p *Payload) MemoizeFields(keys ...string) {
568568 p .missingFields = make (map [string ]struct {}, len (keys ))
569569 }
570570
571- // We memoize all key fields during ingest, it should be rare to
572- // have keys not memoized, we will not prematurely allocate here
571+ // It is rare for a key field to not be memoized.
572+ // Intentionally not allocating memory for keysToFind because it is rarely needed.
573+ // It is worth the compute cost to grow this map on those rare occassions instead
574+ // of allocating memory we rarely use.
575+ // CAUTION: This optimization is under the assumption that MemoizeFields() are only
576+ // called after the first memoization operation. If this assumption ever changes,
577+ // we should reevaluate this optimization
573578 keysToFind := make (map [string ]struct {})
574579 for _ , key := range keys {
575580 if _ , ok := p .missingFields [key ]; ok {
You can’t perform that action at this time.
0 commit comments