summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-11-07 13:47:22 +0100
committerGitHub <noreply@github.com>2016-11-07 13:47:22 +0100
commitd7bfafaa42eb13926d8c4109e665ce11fd5b3bf7 (patch)
tree2a9b9dc57561bbbc18a4fe49ca212fea8ecf959f
parent24c47dd6e7b4652248126199e399c065d55cf7eb (diff)
parentb1a369d2fbb89112d90e54a34f94d4aae1bd1bc6 (diff)
downloadNim-d7bfafaa42eb13926d8c4109e665ce11fd5b3bf7.tar.gz
Merge pull request #5003 from zevlg/strutils-enh
[enh] isUpperAscii*, isLowerAscii* speedup execution by stopping
-rw-r--r--lib/pure/strutils.nim10
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".} =