diff options
| author | Shane Shrybman <shrybman@teksavvy.com> | 2026-02-12 10:43:27 -0500 |
|---|---|---|
| committer | Shane Shrybman <shrybman@teksavvy.com> | 2026-02-12 10:43:27 -0500 |
| commit | a484937fb7b29a9ef7b5087cf11f5104a1825dfc (patch) | |
| tree | f9ccc9e76c656130dfd712a4329689a9327be668 /core/strings | |
| parent | edcefaac12c2ca9e3b3483fb793fa6920b90cebc (diff) | |
strings.compare() can wrap runtime.string_cmp()
Diffstat (limited to 'core/strings')
| -rw-r--r-- | core/strings/strings.odin | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/core/strings/strings.odin b/core/strings/strings.odin index 75c7154af..9b75c558b 100644 --- a/core/strings/strings.odin +++ b/core/strings/strings.odin @@ -242,15 +242,7 @@ Returns: - result: `-1` if `lhs` comes first, `1` if `rhs` comes first, or `0` if they are equal */ compare :: proc "contextless" (lhs, rhs: string) -> (res: int) { - a := transmute([]byte)lhs - b := transmute([]byte)rhs - res = runtime.memory_compare(raw_data(a), raw_data(b), min(len(a), len(b))) - if res == 0 && len(a) != len(b) { - return len(a) <= len(b) ? -1 : +1 - } else if len(a) == 0 && len(b) == 0 { - return 0 - } - return res + return runtime.string_cmp(lhs, rhs) } /* |