cache rope when threads are enabled (#19981)
* cache rope * add threadvar
This commit is contained in:
parent
430a179307
commit
dcb28fd061
1 changed files with 5 additions and 6 deletions
|
|
@ -86,13 +86,12 @@ proc newRope(data: string = ""): Rope =
|
||||||
result.L = -data.len
|
result.L = -data.len
|
||||||
result.data = data
|
result.data = data
|
||||||
|
|
||||||
when not compileOption("threads"):
|
var
|
||||||
var
|
cache {.threadvar.} : array[0..2048*2 - 1, Rope]
|
||||||
cache: array[0..2048*2 - 1, Rope]
|
|
||||||
|
|
||||||
proc resetRopeCache* =
|
proc resetRopeCache* =
|
||||||
for i in low(cache)..high(cache):
|
for i in low(cache)..high(cache):
|
||||||
cache[i] = nil
|
cache[i] = nil
|
||||||
|
|
||||||
proc ropeInvariant(r: Rope): bool =
|
proc ropeInvariant(r: Rope): bool =
|
||||||
if r == nil:
|
if r == nil:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue