diff options
-rw-r--r-- | lib/system.nim | 8 | ||||
-rw-r--r-- | lib/system/seqs_v2.nim | 2 | ||||
-rw-r--r-- | lib/system/strs_v2.nim | 2 | ||||
-rw-r--r-- | lib/system/sysstr.nim | 4 |
4 files changed, 8 insertions, 8 deletions
diff --git a/lib/system.nim b/lib/system.nim index 56fa91ee2..8cd526bd0 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -457,10 +457,6 @@ when not defined(js) and not defined(nimSeqsV2): data: UncheckedArray[char] NimString = ptr NimStringDesc -when notJSnotNims and not defined(nimSeqsV2): - template space(s: PGenericSeq): int {.dirty.} = - s.reserved and not (seqShallowFlag or strlitFlag) - when notJSnotNims: include "system/hti" @@ -1048,6 +1044,10 @@ const hasThreadSupport = compileOption("threads") and not defined(nimscript) hasSharedHeap = defined(boehmgc) or defined(gogc) # don't share heaps; every thread has its own +when notJSnotNims and not defined(nimSeqsV2): + template space(s: PGenericSeq): int = + s.reserved and not (seqShallowFlag or strlitFlag) + when hasThreadSupport and defined(tcc) and not compileOption("tlsEmulation"): # tcc doesn't support TLS {.error: "`--tlsEmulation:on` must be used when using threads with tcc backend".} diff --git a/lib/system/seqs_v2.nim b/lib/system/seqs_v2.nim index 9cf403229..c4e3e3e6b 100644 --- a/lib/system/seqs_v2.nim +++ b/lib/system/seqs_v2.nim @@ -193,7 +193,7 @@ func capacity*[T](self: seq[T]): int {.inline.} = assert lst.capacity == 42 let sek = cast[ptr NimSeqV2[T]](unsafeAddr self) - result = if sek.p != nil: (sek.p.cap and not strlitFlag) else: 0 + result = if sek.p != nil: sek.p.cap and not strlitFlag else: 0 {.pop.} # See https://github.com/nim-lang/Nim/issues/21401 diff --git a/lib/system/strs_v2.nim b/lib/system/strs_v2.nim index a9a104d3d..abdbcd7c3 100644 --- a/lib/system/strs_v2.nim +++ b/lib/system/strs_v2.nim @@ -211,4 +211,4 @@ func capacity*(self: string): int {.inline.} = assert str.capacity == 42 let str = cast[ptr NimStringV2](unsafeAddr self) - result = if str.p != nil: str.p.cap else: 0 + result = if str.p != nil: str.p.cap and not strlitFlag else: 0 diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim index 54d0f2b2f..e4d6479ec 100644 --- a/lib/system/sysstr.nim +++ b/lib/system/sysstr.nim @@ -343,7 +343,7 @@ func capacity*(self: string): int {.inline.} = assert str.capacity == 42 let str = cast[NimString](self) - result = if str != nil: str.reserved else: 0 + result = if str != nil: str.space else: 0 func capacity*[T](self: seq[T]): int {.inline.} = ## Returns the current capacity of the seq. @@ -354,4 +354,4 @@ func capacity*[T](self: seq[T]): int {.inline.} = assert lst.capacity == 42 let sek = cast[PGenericSeq](self) - result = if sek != nil: (sek.reserved and not strlitFlag) else: 0 + result = if sek != nil: sek.space else: 0 |