mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-24 15:03:46 +00:00
use wrapping instead of saturaing subtraction
This commit is contained in:
parent
3fa9712d81
commit
aec3af667d
1 changed files with 2 additions and 2 deletions
|
@ -1066,7 +1066,7 @@ dropPrefix : Str, Str -> Str
|
|||
dropPrefix = \haystack, prefix ->
|
||||
if Str.startsWith haystack prefix then
|
||||
start = Str.countUtf8Bytes prefix
|
||||
len = Num.subSaturated (Str.countUtf8Bytes haystack) start
|
||||
len = Num.subWrap (Str.countUtf8Bytes haystack) start
|
||||
|
||||
substringUnsafe haystack start len
|
||||
else
|
||||
|
@ -1083,7 +1083,7 @@ dropSuffix : Str, Str -> Str
|
|||
dropSuffix = \haystack, suffix ->
|
||||
if Str.endsWith haystack suffix then
|
||||
start = 0
|
||||
len = Num.subSaturated (Str.countUtf8Bytes haystack) (Str.countUtf8Bytes suffix)
|
||||
len = Num.subWrap (Str.countUtf8Bytes haystack) (Str.countUtf8Bytes suffix)
|
||||
|
||||
substringUnsafe haystack start len
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue