Make the string type elements "immutable", akin to char const * in C
Allows for extra security and optimization benefits
This commit is contained in:
1 parent
7fbe0a6f23
commit
9db81498d8
25 files changed
+255
-176
No files matched your search
+3
-1
@@ -282,5 +282,7 @@ compare_f64s :: proc(a, b: f64) -> int {
|
||||
return 0;
|
||||
}
|
||||
compare_strings :: proc(a, b: string) -> int {
|
||||
return mem.compare_byte_ptrs(&a[0], &b[0], min(len(a), len(b)));
|
||||
x := transmute(mem.Raw_String)a;
|
||||
y := transmute(mem.Raw_String)b;
|
||||
return mem.compare_byte_ptrs(x.data, y.data, min(x.len, y.len));
|
||||
}
|
||||
Reference in new issue
Block a user