better memory tracking

This commit is contained in:
Andreas Rumpf 2016-11-22 08:24:39 +01:00
commit 439f43fc52
2 changed files with 64 additions and 55 deletions

View file

@ -1309,10 +1309,12 @@ proc join*[T: not string](a: openArray[T], sep: string = ""): string {.
type
SkipTable = array[char, int]
{.push profiler: off.}
proc preprocessSub(sub: string, a: var SkipTable) =
var m = len(sub)
for i in 0..0xff: a[chr(i)] = m+1
for i in 0..m-1: a[sub[i]] = m-i
{.pop.}
proc findAux(s, sub: string, start: int, a: SkipTable): int =
# Fast "quick search" algorithm: