diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2022-07-07 20:14:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-07 14:14:05 +0200 |
commit | dcb28fd061743ba141b3914501512b5eb352aa1b (patch) | |
tree | 4f80639bfa096178e7a06b63d96503e0716b87c3 /compiler | |
parent | 430a1793075866179b34790a461936023fca1c0a (diff) | |
download | Nim-dcb28fd061743ba141b3914501512b5eb352aa1b.tar.gz |
cache rope when threads are enabled (#19981)
* cache rope * add threadvar
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ropes.nim | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/compiler/ropes.nim b/compiler/ropes.nim index a44d84ddc..610159c75 100644 --- a/compiler/ropes.nim +++ b/compiler/ropes.nim @@ -86,13 +86,12 @@ proc newRope(data: string = ""): Rope = result.L = -data.len result.data = data -when not compileOption("threads"): - var - cache: array[0..2048*2 - 1, Rope] +var + cache {.threadvar.} : array[0..2048*2 - 1, Rope] - proc resetRopeCache* = - for i in low(cache)..high(cache): - cache[i] = nil +proc resetRopeCache* = + for i in low(cache)..high(cache): + cache[i] = nil proc ropeInvariant(r: Rope): bool = if r == nil: |