mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-09 06:23:25 +00:00
Fix seq.capacity (#22488)
This commit is contained in:
committed by
GitHub
parent
940b1607b8
commit
299394d21a
@@ -141,7 +141,7 @@ proc newSeq[T](s: var seq[T], len: Natural) =
|
||||
|
||||
|
||||
template capacityImpl(sek: NimSeqV2): int =
|
||||
if sek.p != nil: (xu.p.cap and not strlitFlag) else: 0
|
||||
if sek.p != nil: (sek.p.cap and not strlitFlag) else: 0
|
||||
|
||||
func capacity*[T](self: seq[T]): int {.inline.} =
|
||||
## Returns the current capacity of the seq.
|
||||
@@ -153,7 +153,7 @@ func capacity*[T](self: seq[T]): int {.inline.} =
|
||||
|
||||
{.cast(noSideEffect).}:
|
||||
let sek = unsafeAddr self
|
||||
result = capacityImpl(cast[ptr NimSeqV2](sek)[])
|
||||
result = capacityImpl(cast[ptr NimSeqV2[T]](sek)[])
|
||||
|
||||
|
||||
{.pop.} # See https://github.com/nim-lang/Nim/issues/21401
|
||||
|
||||
Reference in New Issue
Block a user