summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorn5m <72841454+n5m@users.noreply.github.com>2021-06-03 12:25:52 +0000
committerGitHub <noreply@github.com>2021-06-03 14:25:52 +0200
commit9df631a379998f554748697da7fe95ce4463cb83 (patch)
tree51de1cc88c91099e99b793fe6ee5baa72c012329 /lib/pure
parent282d61bafa4f1b06e1328cf8e517f556fb86d592 (diff)
downloadNim-9df631a379998f554748697da7fe95ce4463cb83.tar.gz
reuse algorithm.fill while building SkipTable (#18138)
* reuse algorithm.fill while building SkipTable

* Update lib/pure/strutils.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/strutils.nim14
1 files changed, 2 insertions, 12 deletions
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim
index 3fb67ead1..8e0a6158b 100644
--- a/lib/pure/strutils.nim
+++ b/lib/pure/strutils.nim
@@ -72,7 +72,7 @@ runnableExamples:
 
 import parseutils
 from math import pow, floor, log10
-from algorithm import reverse
+from algorithm import fill, reverse
 import std/enumutils
 
 from unicode import toLower, toUpper
@@ -1779,17 +1779,7 @@ func initSkipTable*(a: var SkipTable, sub: string) {.rtl,
     extern: "nsuInitSkipTable".} =
   ## Preprocess table `a` for `sub`.
   let m = len(sub)
-  var i = 0
-  while i <= 0xff-7:
-    a[chr(i + 0)] = m
-    a[chr(i + 1)] = m
-    a[chr(i + 2)] = m
-    a[chr(i + 3)] = m
-    a[chr(i + 4)] = m
-    a[chr(i + 5)] = m
-    a[chr(i + 6)] = m
-    a[chr(i + 7)] = m
-    i += 8
+  fill(a, m)
 
   for i in 0 ..< m - 1:
     a[sub[i]] = m - 1 - i