isAlphaNumberic and isDigit improvement + tests (#6579)
if we encounter a character that does not satisfy the proc, we return immediately, without continuing to loop over the rest of the chars in the string.
This commit is contained in:
parent
c051244859
commit
ce04288d64
2 changed files with 23 additions and 2 deletions
|
|
@ -138,7 +138,8 @@ proc isAlphaNumeric*(s: string): bool {.noSideEffect, procvar,
|
|||
|
||||
result = true
|
||||
for c in s:
|
||||
result = c.isAlphaNumeric() and result
|
||||
if not c.isAlphaNumeric():
|
||||
return false
|
||||
|
||||
proc isDigit*(s: string): bool {.noSideEffect, procvar,
|
||||
rtl, extern: "nsuIsDigitStr".}=
|
||||
|
|
@ -153,7 +154,8 @@ proc isDigit*(s: string): bool {.noSideEffect, procvar,
|
|||
|
||||
result = true
|
||||
for c in s:
|
||||
result = c.isDigit() and result
|
||||
if not c.isDigit():
|
||||
return false
|
||||
|
||||
proc isSpaceAscii*(s: string): bool {.noSideEffect, procvar,
|
||||
rtl, extern: "nsuIsSpaceAsciiStr".}=
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue