Descriptionruntime: optimize some hash lookups.
When comparing strings, check these (in order):
- length mismatch => not equal
- string pointer equal => equal
- if length is short:
- memeq on body
- if length is long:
- compare first&last few bytes, if different => not equal
- save entry as a possible match
- after checking every entry, if there is only one possible
match, use memeq on that entry. Otherwise, fallback to hash.
benchmark old ns/op new ns/op delta
BenchmarkSameLengthMap 43 4 -89.77%
Fixes issue 5194.
Update issue 3885.
Patch Set 1 #Patch Set 2 : diff -r 521dd78cd28e https://khr%40golang.org@code.google.com/p/go/ #Patch Set 3 : diff -r 521dd78cd28e https://khr%40golang.org@code.google.com/p/go/ #Patch Set 4 : diff -r 2f6ebc31b696 https://khr%40golang.org@code.google.com/p/go/ #
MessagesTotal messages: 5
|