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:
parent
7248d8422e
commit
646df49c74
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user