1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: fix string.hash method for gcc -O2 (#5794)

This commit is contained in:
Uwe Krüger 2020-07-11 00:18:52 +02:00 committed by GitHub
parent 7248d8422e
commit 646df49c74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1326,13 +1326,13 @@ pub fn (c byte) is_white() bool {
pub fn (s string) hash() int { pub fn (s string) hash() int {
// mut h := s.hash_cache // mut h := s.hash_cache
mut h := 0 mut h := u32(0)
if h == 0 && s.len > 0 { if h == 0 && s.len > 0 {
for c in s { for c in s {
h = h * 31 + int(c) h = h * 31 + u32(c)
} }
} }
return h return int(h)
} }
pub fn (s string) bytes() []byte { pub fn (s string) bytes() []byte {