-
Notifications
You must be signed in to change notification settings - Fork 18k
reflect: remove calling mapiterkey and mapiterelem #69416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
In general, performance improvements with no user visible effect can just be submitted. A proposal doesn't need to be approved first unless it's doing something unusual to get the performance. |
Change https://go.dev/cl/612616 mentions this issue: |
Taking this out of the proposal process. |
Change https://go.dev/cl/613395 mentions this issue: |
Hi, Go team.
I'm working on optimizing iterating over map for an internal data encoding project.
And in our case, I found that one of the bottlenecks is
reflect.MapIter
.Next
.It can be improved by removing calling
mapiterkey
.coz we have already copied
hiter
struct fromruntime
for performance concern.To make it further, we can use
key
andelem
ofhiter
struct directly without callingmapiterkey
andmapiterelem
This mainly impacts the
Next
method ofreflect.MapIter
.I ran the
BenchmarkMapIterNext
benchmark inreflect/benchmark_test.go
, and here is the output:I would like to raise CR if you're OK with it.
The text was updated successfully, but these errors were encountered: