aboutsummaryrefslogtreecommitdiff
path: root/src/string.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-09-10 11:24:50 +0100
committerGinger Bill <bill@gingerbill.org>2016-09-10 11:24:50 +0100
commit7509cdceb83dbbeb69b1b85b956cf45a62959b26 (patch)
treeebed5cfd541b87f06db0f46fb1cc68c8e93ea4dd /src/string.cpp
parent6979678ff947cecc8e6e0d0e8ceea7e0304d3f4e (diff)
Default struct member reordering for minimal size
Rule: largest members to smallest; if same size, order in source order
Diffstat (limited to 'src/string.cpp')
-rw-r--r--src/string.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/string.cpp b/src/string.cpp
index 743d5dcd4..0e243f66e 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -43,10 +43,7 @@ gb_inline b32 are_strings_equal_ignore_case(String a, String b) {
return false;
}
-GB_COMPARE_PROC(string_cmp) {
- String x = *cast(String *)a;
- String y = *cast(String *)b;
-
+int string_compare(String x, String y) {
if (x.len == y.len &&
x.text == y.text) {
return 0;
@@ -65,9 +62,9 @@ GB_COMPARE_PROC(string_cmp) {
isize *lb = cast(isize *)y.text;
for (; curr_block < fast; curr_block++) {
- if ((la[curr_block] ^ lb[curr_block]) != 0) {
+ if (la[curr_block] ^ lb[curr_block]) {
for (isize pos = curr_block*gb_size_of(isize); pos < n; pos++) {
- if ((x.text[pos] ^ y.text[pos]) != 0) {
+ if (x.text[pos] ^ y.text[pos]) {
return cast(int)x.text[pos] - cast(int)y.text[pos];
}
}
@@ -75,7 +72,7 @@ GB_COMPARE_PROC(string_cmp) {
}
for (; offset < n; offset++) {
- if ((x.text[offset] ^ y.text[offset]) != 0) {
+ if (x.text[offset] ^ y.text[offset]) {
return cast(int)x.text[offset] - cast(int)y.text[offset];
}
}
@@ -83,6 +80,12 @@ GB_COMPARE_PROC(string_cmp) {
return 0;
}
+GB_COMPARE_PROC(string_cmp_proc) {
+ String x = *(String *)a;
+ String y = *(String *)b;
+ return string_compare(x, y);
+}
+
gb_inline isize string_extension_position(String str) {
isize dot_pos = -1;