diff options
Diffstat (limited to 'lib/system/strs_v2.nim')
-rw-r--r-- | lib/system/strs_v2.nim | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/system/strs_v2.nim b/lib/system/strs_v2.nim index e161172b2..a9a104d3d 100644 --- a/lib/system/strs_v2.nim +++ b/lib/system/strs_v2.nim @@ -202,9 +202,6 @@ proc prepareMutation*(s: var string) {.inline.} = nimPrepareStrMutationV2(cast[ptr NimStringV2](s)[]) -template capacityImpl(str: NimStringV2): int = - if str.p != nil: str.p.cap else: 0 - func capacity*(self: string): int {.inline.} = ## Returns the current capacity of the string. # See https://github.com/nim-lang/RFCs/issues/460 @@ -213,6 +210,5 @@ func capacity*(self: string): int {.inline.} = str.add "Nim" assert str.capacity == 42 - {.cast(noSideEffect).}: - let str = unsafeAddr self - result = capacityImpl(cast[ptr NimStringV2](str)[]) + let str = cast[ptr NimStringV2](unsafeAddr self) + result = if str.p != nil: str.p.cap else: 0 |