Skip to content

Commit 381744b

Browse files
committed
update comment
1 parent eb8c1ce commit 381744b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

types/payload.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff 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 {

0 commit comments

Comments
 (0)