From: Brendan Hansen Date: Sat, 24 Apr 2021 16:39:19 +0000 (-0500) Subject: fixed a small bug because && does not short circuit X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=80fb6e3874aca287668344fde6cd9abda0af784f;p=onyx.git fixed a small bug because && does not short circuit --- 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]);