@@ -45,62 +45,63 @@ func (iter *Iterator) ReadObject() (ret string) {
45
45
}
46
46
}
47
47
48
- func (iter * Iterator ) readFieldHash () int32 {
48
+ // CaseInsensitive
49
+ func (iter * Iterator ) readFieldHash () int64 {
49
50
hash := int64 (0x811c9dc5 )
50
51
c := iter .nextToken ()
51
- if c == '"' {
52
- for {
53
- for i := iter .head ; i < iter .tail ; i ++ {
54
- // require ascii string and no escape
55
- b := iter .buf [i ]
56
- if ! iter .cfg .objectFieldMustBeSimpleString && b == '\\' {
57
- iter .head = i
58
- for _ , b := range iter .readStringSlowPath () {
59
- if 'A' <= b && b <= 'Z' {
60
- b += 'a' - 'A'
61
- }
62
- hash ^= int64 (b )
63
- hash *= 0x1000193
64
- }
65
- c = iter .nextToken ()
66
- if c != ':' {
67
- iter .ReportError ("readFieldHash" , `expect :, but found ` + string ([]byte {c }))
68
- return 0
52
+ if c != '"' {
53
+ iter .ReportError ("readFieldHash" , `expect ", but found ` + string ([]byte {c }))
54
+ return 0
55
+ }
56
+ for {
57
+ for i := iter .head ; i < iter .tail ; i ++ {
58
+ // require ascii string and no escape
59
+ b := iter .buf [i ]
60
+ if b == '\\' {
61
+ iter .head = i
62
+ for _ , b := range iter .readStringSlowPath () {
63
+ if 'A' <= b && b <= 'Z' {
64
+ b += 'a' - 'A'
69
65
}
70
- return int32 (hash )
66
+ hash ^= int64 (b )
67
+ hash *= 0x1000193
71
68
}
72
- if b == '"' {
73
- iter .head = i + 1
74
- c = iter .nextToken ()
75
- if c != ':' {
76
- iter .ReportError ("readFieldHash" , `expect :, but found ` + string ([]byte {c }))
77
- return 0
78
- }
79
- return int32 (hash )
69
+ c = iter .nextToken ()
70
+ if c != ':' {
71
+ iter .ReportError ("readFieldHash" , `expect :, but found ` + string ([]byte {c }))
72
+ return 0
80
73
}
81
- if 'A' <= b && b <= 'Z' {
82
- b += 'a' - 'A'
74
+ return hash
75
+ }
76
+ if b == '"' {
77
+ iter .head = i + 1
78
+ c = iter .nextToken ()
79
+ if c != ':' {
80
+ iter .ReportError ("readFieldHash" , `expect :, but found ` + string ([]byte {c }))
81
+ return 0
83
82
}
84
- hash ^= int64 (b )
85
- hash *= 0x1000193
83
+ return hash
86
84
}
87
- if ! iter .loadMore () {
88
- iter .ReportError ("readFieldHash" , `incomplete field name` )
89
- return 0
85
+ if 'A' <= b && b <= 'Z' {
86
+ b += 'a' - 'A'
90
87
}
88
+ hash ^= int64 (b )
89
+ hash *= 0x1000193
90
+ }
91
+ if ! iter .loadMore () {
92
+ iter .ReportError ("readFieldHash" , `incomplete field name` )
93
+ return 0
91
94
}
92
95
}
93
- iter .ReportError ("readFieldHash" , `expect ", but found ` + string ([]byte {c }))
94
- return 0
95
96
}
96
97
97
- func calcHash (str string ) int32 {
98
+ func calcHash (str string ) int64 {
98
99
hash := int64 (0x811c9dc5 )
99
100
for _ , b := range str {
100
101
hash ^= int64 (unicode .ToLower (b ))
101
102
hash *= 0x1000193
102
103
}
103
- return int32 (hash )
104
+ return int64 (hash )
104
105
}
105
106
106
107
// ReadObjectCB read object with callback, the key is ascii only and field name not copied
0 commit comments