From 80fb6e3874aca287668344fde6cd9abda0af784f Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sat, 24 Apr 2021 11:39:19 -0500 Subject: [PATCH] fixed a small bug because && does not short circuit --- core/string.onyx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/string.onyx b/core/string.onyx index e9ad0fc1..6bf5a7dc 100644 --- a/core/string.onyx +++ b/core/string.onyx @@ -111,7 +111,10 @@ contains :: proc { // it will work perfectly yet. - brendanfh 2020/12/21 compare :: (str1: str, str2: str) -> i32 { i := 0; - while i < str1.count && i < str2.count && str1[i] == str2[i] do i += 1; + while i < str1.count && i < str2.count { + if str1[i] == str2[i] do i += 1; + else do break; + } if i == str1.count && i == str2.count do return 0; return ~~(str1[i] - str2[i]); -- 2.25.1