diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-11-07 13:47:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-07 13:47:22 +0100 |
commit | d7bfafaa42eb13926d8c4109e665ce11fd5b3bf7 (patch) | |
tree | 2a9b9dc57561bbbc18a4fe49ca212fea8ecf959f | |
parent | 24c47dd6e7b4652248126199e399c065d55cf7eb (diff) | |
parent | b1a369d2fbb89112d90e54a34f94d4aae1bd1bc6 (diff) | |
download | Nim-d7bfafaa42eb13926d8c4109e665ce11fd5b3bf7.tar.gz |
Merge pull request #5003 from zevlg/strutils-enh
[enh] isUpperAscii*, isLowerAscii* speedup execution by stopping
-rw-r--r-- | lib/pure/strutils.nim | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index bfc32bc71..129869373 100644 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -179,9 +179,10 @@ proc isLowerAscii*(s: string): bool {.noSideEffect, procvar, if s.len() == 0: return false - result = true for c in s: - result = c.isLowerAscii() and result + if not c.isLowerAscii(): + return false + true proc isUpperAscii*(s: string): bool {.noSideEffect, procvar, rtl, extern: "nsuIsUpperAsciiStr".}= @@ -193,9 +194,10 @@ proc isUpperAscii*(s: string): bool {.noSideEffect, procvar, if s.len() == 0: return false - result = true for c in s: - result = c.isUpperAscii() and result + if not c.isUpperAscii(): + return false + true proc toLowerAscii*(c: char): char {.noSideEffect, procvar, rtl, extern: "nsuToLowerAsciiChar".} = |