mirror of
https://github.com/json-iterator/go.git
synced 2025-04-20 11:28:49 +02:00
fix #286 calcHash should use byte not rune to calc hash
This commit is contained in:
parent
10a568c511
commit
0260c89b54
@ -2,7 +2,7 @@ package jsoniter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"unicode"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ReadObject read one field from object.
|
// ReadObject read one field from object.
|
||||||
@ -96,13 +96,12 @@ func (iter *Iterator) readFieldHash() int64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func calcHash(str string, caseSensitive bool) int64 {
|
func calcHash(str string, caseSensitive bool) int64 {
|
||||||
hash := int64(0x811c9dc5)
|
if !caseSensitive {
|
||||||
for _, b := range str {
|
str = strings.ToLower(str)
|
||||||
if caseSensitive {
|
|
||||||
hash ^= int64(b)
|
|
||||||
} else {
|
|
||||||
hash ^= int64(unicode.ToLower(b))
|
|
||||||
}
|
}
|
||||||
|
hash := int64(0x811c9dc5)
|
||||||
|
for _, b := range []byte(str) {
|
||||||
|
hash ^= int64(b)
|
||||||
hash *= 0x1000193
|
hash *= 0x1000193
|
||||||
}
|
}
|
||||||
return int64(hash)
|
return int64(hash)
|
||||||
|
@ -145,6 +145,9 @@ func init() {
|
|||||||
(*struct {
|
(*struct {
|
||||||
Field bool `json:",omitempty,string"`
|
Field bool `json:",omitempty,string"`
|
||||||
})(nil),
|
})(nil),
|
||||||
|
(*struct {
|
||||||
|
Field bool `json:"中文"`
|
||||||
|
})(nil),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user