diff options
author | def <dennis@felsin9.de> | 2015-03-03 22:23:35 +0100 |
---|---|---|
committer | def <dennis@felsin9.de> | 2015-03-03 22:23:35 +0100 |
commit | fa3620be9e9ca30bbfcfee25ee4ef85c1ece47f6 (patch) | |
tree | fb760bf0fc1f8a0ee2ea5d3640d8ebbdc04cee31 | |
parent | 8f43979cf6308c9d7e14a0d87c0faf227e1c4afe (diff) | |
download | Nim-fa3620be9e9ca30bbfcfee25ee4ef85c1ece47f6.tar.gz |
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.
-rw-r--r-- | lib/system/sysstr.nim | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim index cfbc24f0c..c0b337dcd 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) + |