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

fix 'v -debug examples/hello_world.v'

This commit is contained in:
Delyan Angelov
2019-10-10 20:02:32 +03:00
committed by Alexander Medvednikov
parent 1b79964827
commit f3abb9e682
3 changed files with 7 additions and 10 deletions

View File

@ -14,8 +14,6 @@ module builtin
the performance gains are basically non-existent.
*/
import math
struct hashmap {
cap int
keys []string
@ -52,7 +50,7 @@ fn new_hashmap(planned_nr_items int) hashmap {
}
fn (m mut hashmap) set(key string, val int) {
hash := int(math.abs(key.hash()))
mut hash := int(b_fabs( key.hash() ))
idx := hash % m.cap
if m.table[idx].key.len != 0 {
//println('\nset() idx=$idx key="$key" hash="$hash" val=$val')
@ -69,7 +67,7 @@ fn (m mut hashmap) set(key string, val int) {
}
fn (m mut hashmap) get(key string) int {
hash := int(math.abs(key.hash()))
hash := int(b_fabs( key.hash() ))
idx := hash % m.cap
mut e := &m.table[idx]
for e.next != 0 { // todo unsafe {
@ -81,4 +79,4 @@ fn (m mut hashmap) get(key string) int {
return e.val
}
[inline] fn b_fabs(v int) f64 { return if v < 0 { -v } else { v } }