From fa3620be9e9ca30bbfcfee25ee4ef85c1ece47f6 Mon Sep 17 00:00:00 2001 From: def Date: Tue, 3 Mar 2015 22:23:35 +0100 Subject: [PATCH] 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. --- lib/system/sysstr.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim index cfbc24f0cf..c0b337dcdc 100644 --- a/lib/system/sysstr.nim +++ b/lib/system/sysstr.nim @@ -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) +