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:
def 2015-03-03 22:23:35 +01:00
commit fa3620be9e

View file

@ -77,13 +77,13 @@ proc copyString(src: NimString): NimString {.compilerRtl.} =
if (src.reserved and seqShallowFlag) != 0:
result = src
else:
result = rawNewString(src.space)
result = rawNewString(src.len)
result.len = src.len
c_memcpy(result.data, src.data, (src.len + 1) * sizeof(char))
proc copyStringRC1(src: NimString): NimString {.compilerRtl.} =
if src != nil:
var s = src.space
var s = src.len
if s < 8: s = 7
when declared(newObjRC1):
result = cast[NimString](newObjRC1(addr(strDesc), sizeof(TGenericSeq) +