-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MapStr accessor optimisations (#6837)
* MapStr accessor optimisations Replace walkMap + interface callbacks with mapFind function, providing all the information required by the different accessor operations. The mapFind function uses a while loop, searching for the next sub-key in the key-path. This is a tail-call optimisation on walkMapRecursive. By searching for the next sub-string and using slices, allocations on key-paths with dots are greatly reduced. Benchmark results: benchmark old ns/op new ns/op delta BenchmarkWalkMap/Get-4 1125 30.8 -97.26% BenchmarkWalkMap/Put-4 890 458 -48.54% BenchmarkWalkMap/PutMissing-4 813 401 -50.68% BenchmarkWalkMap/HasKey-4 565 157 -72.21% BenchmarkWalkMap/HasKeyFirst-4 23.9 12.4 -48.12% BenchmarkWalkMap/Delete-4 860 457 -46.86% benchmark old allocs new allocs delta BenchmarkWalkMap/Get-4 7 0 -100.00% BenchmarkWalkMap/Put-4 10 4 -60.00% BenchmarkWalkMap/PutMissing-4 10 4 -60.00% BenchmarkWalkMap/HasKey-4 5 0 -100.00% BenchmarkWalkMap/HasKeyFirst-4 0 0 +0.00% BenchmarkWalkMap/Delete-4 10 4 -60.00% benchmark old bytes new bytes delta BenchmarkWalkMap/Get-4 432 0 -100.00% BenchmarkWalkMap/Put-4 1120 672 -40.00% BenchmarkWalkMap/PutMissing-4 1120 672 -40.00% BenchmarkWalkMap/HasKey-4 160 0 -100.00% BenchmarkWalkMap/HasKeyFirst-4 0 0 +0.00% BenchmarkWalkMap/Delete-4 1120 672 -40.00%
- Loading branch information
Showing
2 changed files
with
123 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters