diff options
| author | gingerBill <bill@gingerbill.org> | 2024-03-27 12:54:37 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-03-27 12:54:37 +0000 |
| commit | 6422c090f21c0b5ef035bb2ea784b1d9fb26f422 (patch) | |
| tree | 78a55edf693c3c3f42802f5d8617943ff9e6540a /core/hash/mini.odin | |
| parent | 3bc7c513258ac59700961b417826e13a3fe6a2cf (diff) | |
Make hash procedures contextless where possible
Diffstat (limited to 'core/hash/mini.odin')
| -rw-r--r-- | core/hash/mini.odin | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/hash/mini.odin b/core/hash/mini.odin index 98b1b4ba3..6b476f535 100644 --- a/core/hash/mini.odin +++ b/core/hash/mini.odin @@ -1,6 +1,6 @@ package hash -ginger_hash8 :: proc(x: u8) -> u8 { +ginger_hash8 :: proc "contextless" (x: u8) -> u8 { h := x * 251 h += ~(x << 3) h ~= (x >> 1) @@ -11,7 +11,7 @@ ginger_hash8 :: proc(x: u8) -> u8 { } -ginger_hash16 :: proc(x: u16) -> u16 { +ginger_hash16 :: proc "contextless" (x: u16) -> u16 { z := (x << 8) | (x >> 8) h := z h += ~(z << 5) @@ -24,14 +24,14 @@ ginger_hash16 :: proc(x: u16) -> u16 { } -ginger8 :: proc(data: []byte) -> u8 { +ginger8 :: proc "contextless" (data: []byte) -> u8 { h := ginger_hash8(0) for b in data { h ~= ginger_hash8(b) } return h } -ginger16 :: proc(data: []byte) -> u16 { +ginger16 :: proc "contextless" (data: []byte) -> u16 { h := ginger_hash16(0) for b in data { h ~= ginger_hash16(u16(b)) |