aboutsummaryrefslogtreecommitdiff
path: root/core/mem.odin
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-01-07 11:44:42 +0000
committerGinger Bill <bill@gingerbill.org>2017-01-07 11:44:42 +0000
commit703e1aa2bcf6bb059a3dd0e12a02cf02ed5449cf (patch)
treed67712be7ccd274efa9f0042415356e769b12dec /core/mem.odin
parentb1e35b6da3e335376339965ad2e26d7e275de3c5 (diff)
Fix core library; Disable adding entity definitions for blank identifiersv0.0.5e
Diffstat (limited to 'core/mem.odin')
-rw-r--r--core/mem.odin33
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;
}