mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +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 ->
|
dropPrefix = \haystack, prefix ->
|
||||||
if Str.startsWith haystack prefix then
|
if Str.startsWith haystack prefix then
|
||||||
start = Str.countUtf8Bytes prefix
|
start = Str.countUtf8Bytes prefix
|
||||||
len = Num.subSaturated (Str.countUtf8Bytes haystack) start
|
len = Num.subWrap (Str.countUtf8Bytes haystack) start
|
||||||
|
|
||||||
substringUnsafe haystack start len
|
substringUnsafe haystack start len
|
||||||
else
|
else
|
||||||
|
@ -1083,7 +1083,7 @@ dropSuffix : Str, Str -> Str
|
||||||
dropSuffix = \haystack, suffix ->
|
dropSuffix = \haystack, suffix ->
|
||||||
if Str.endsWith haystack suffix then
|
if Str.endsWith haystack suffix then
|
||||||
start = 0
|
start = 0
|
||||||
len = Num.subSaturated (Str.countUtf8Bytes haystack) (Str.countUtf8Bytes suffix)
|
len = Num.subWrap (Str.countUtf8Bytes haystack) (Str.countUtf8Bytes suffix)
|
||||||
|
|
||||||
substringUnsafe haystack start len
|
substringUnsafe haystack start len
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue