diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-01-07 11:44:42 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-01-07 11:44:42 +0000 |
| commit | 703e1aa2bcf6bb059a3dd0e12a02cf02ed5449cf (patch) | |
| tree | d67712be7ccd274efa9f0042415356e769b12dec /core/mem.odin | |
| parent | b1e35b6da3e335376339965ad2e26d7e275de3c5 (diff) | |
Fix core library; Disable adding entity definitions for blank identifiersv0.0.5e
Diffstat (limited to 'core/mem.odin')
| -rw-r--r-- | core/mem.odin | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/core/mem.odin b/core/mem.odin index f163a219f..ee358fef4 100644 --- a/core/mem.odin +++ b/core/mem.odin @@ -26,37 +26,16 @@ copy_non_overlapping :: proc(dst, src: rawptr, len: int) -> rawptr #link_name "_ } compare :: proc(dst, src: rawptr, n: int) -> int #link_name "__mem_compare" { - // Translation of http://mgronhol.github.io/fast-strcmp/ a := slice_ptr(dst as ^byte, n); b := slice_ptr(src as ^byte, n); - - fast := n/size_of(int) + 1; - offset := (fast-1)*size_of(int); - curr_block := 0; - if n <= size_of(int) { - fast = 0; - } - - la := slice_ptr(^a[0] as ^int, fast); - lb := slice_ptr(^b[0] as ^int, fast); - - for _ : curr_block ..< fast { - if (la[curr_block] ~ lb[curr_block]) != 0 { - for pos : curr_block*size_of(int) ..< n { - if (a[pos] ~ b[pos]) != 0 { - return a[pos] as int - b[pos] as int; - } - } + for i : 0..<n { + match { + case a[i] < b[i]: + return -1; + case a[i] > b[i]: + return +1; } - } - - for _ : offset ..< n { - if (a[offset] ~ b[offset]) != 0 { - return a[offset] as int - b[offset] as int; - } - } - return 0; } |