diff options
author | Josh Bleecher Snyder <josharian@gmail.com> | 2021-05-20 09:57:04 -0700 |
---|---|---|
committer | Josh Bleecher Snyder <josharian@gmail.com> | 2021-09-05 23:09:32 +0000 |
commit | 1b2d794ca3ba60c2dbc958a271662784a7122739 (patch) | |
tree | b0bcc00ae0940735212a0a33e30cd6c85871ca55 /src/reflect/all_test.go | |
parent | 9133245be7365c23fcd60e3bb60ebb614970cdab (diff) | |
download | go-1b2d794ca3ba60c2dbc958a271662784a7122739.tar.gz go-1b2d794ca3ba60c2dbc958a271662784a7122739.zip |
reflect: allocate hiter as part of MapIter
This reduces the number of allocations per
reflect map iteration from two to one.
For #46293
Change-Id: Ibcff5f42fc512e637b6e460bad4518e7ac83d4c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/321889
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/reflect/all_test.go')
-rw-r--r-- | src/reflect/all_test.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 40ac6a95fa..6cb603cb16 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -370,10 +370,9 @@ func TestMapIterSet(t *testing.T) { iter.SetValue(e) } })) - // Making a *MapIter and making an hiter both allocate. - // Those should be the only two allocations. - if got != 2 { - t.Errorf("wanted 2 allocs, got %d", got) + // Making a *MapIter allocates. This should be the only allocation. + if got != 1 { + t.Errorf("wanted 1 alloc, got %d", got) } } |