Only copy strings to their size, not capacity
Capacity may be much bigger, so we end up with strings that are much larger than they have to be and have to copy more as well.
This commit is contained in:
parent
8f43979cf6
commit
fa3620be9e
1 changed files with 2 additions and 2 deletions
|
|
@ -77,13 +77,13 @@ proc copyString(src: NimString): NimString {.compilerRtl.} =
|
||||||
if (src.reserved and seqShallowFlag) != 0:
|
if (src.reserved and seqShallowFlag) != 0:
|
||||||
result = src
|
result = src
|
||||||
else:
|
else:
|
||||||
result = rawNewString(src.space)
|
result = rawNewString(src.len)
|
||||||
result.len = src.len
|
result.len = src.len
|
||||||
c_memcpy(result.data, src.data, (src.len + 1) * sizeof(char))
|
c_memcpy(result.data, src.data, (src.len + 1) * sizeof(char))
|
||||||
|
|
||||||
proc copyStringRC1(src: NimString): NimString {.compilerRtl.} =
|
proc copyStringRC1(src: NimString): NimString {.compilerRtl.} =
|
||||||
if src != nil:
|
if src != nil:
|
||||||
var s = src.space
|
var s = src.len
|
||||||
if s < 8: s = 7
|
if s < 8: s = 7
|
||||||
when declared(newObjRC1):
|
when declared(newObjRC1):
|
||||||
result = cast[NimString](newObjRC1(addr(strDesc), sizeof(TGenericSeq) +
|
result = cast[NimString](newObjRC1(addr(strDesc), sizeof(TGenericSeq) +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue