aboutsummaryrefslogtreecommitdiff
path: root/src/reflect/value.go
diff options
context:
space:
mode:
authorMartin Möhrmann <martin@golang.org>2021-10-31 17:58:07 +0100
committerMartin Möhrmann <martin@golang.org>2021-10-31 18:39:05 +0000
commit89c527007f75884a78ffede5d493ec021e7dfcdc (patch)
tree9fba4a42a987b9eaabf8195acbd24ac70562ec03 /src/reflect/value.go
parentfd09e88722e0af150bf8960e95e8da500ad91001 (diff)
downloadgo-89c527007f75884a78ffede5d493ec021e7dfcdc.tar.gz
go-89c527007f75884a78ffede5d493ec021e7dfcdc.zip
reflect: avoid stack copies of hiter
Use a pointer reciever to avoid copying the hiter struct when checking if it is intialized. Found through profiling that showed reflect map iteration spending a good amount of time in duffcopy. This change will also help other MapIter methods checking hiter struct initialization like Value() and Key(). name old time/op new time/op delta MapIterNext-12 97.9ns ± 4% 83.8ns ± 2% -14.37% (p=0.000 n=10+10) Change-Id: I73ab964fa28061ee7e6d5c663a85048bd2e0274e Reviewed-on: https://go-review.googlesource.com/c/go/+/360254 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Trust: Josh Bleecher Snyder <josharian@gmail.com> Trust: Martin Möhrmann <martin@golang.org>
Diffstat (limited to 'src/reflect/value.go')
-rw-r--r--src/reflect/value.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/reflect/value.go b/src/reflect/value.go
index 90edf8e31d..ecf9dd7bc8 100644
--- a/src/reflect/value.go
+++ b/src/reflect/value.go
@@ -1665,7 +1665,7 @@ type hiter struct {
checkBucket uintptr
}
-func (h hiter) initialized() bool {
+func (h *hiter) initialized() bool {
return h.t != nil
}