fixes #10845
This commit is contained in:
parent
16355de5eb
commit
8e5c1436ad
1 changed files with 20 additions and 15 deletions
|
|
@ -116,22 +116,27 @@ proc newOwnedString(src: NimString; n: int): NimString =
|
||||||
|
|
||||||
proc copyStringRC1(src: NimString): NimString {.compilerRtl.} =
|
proc copyStringRC1(src: NimString): NimString {.compilerRtl.} =
|
||||||
if src != nil:
|
if src != nil:
|
||||||
when declared(newObjRC1) and not defined(gcRegions):
|
if (src.reserved and seqShallowFlag) != 0:
|
||||||
var s = src.len
|
result = src
|
||||||
if s < 7: s = 7
|
when declared(incRef):
|
||||||
result = cast[NimString](newObjRC1(addr(strDesc), sizeof(TGenericSeq) +
|
incRef(usrToCell(result))
|
||||||
s+1))
|
|
||||||
result.reserved = s
|
|
||||||
when defined(gogc):
|
|
||||||
result.elemSize = 1
|
|
||||||
else:
|
else:
|
||||||
result = rawNewStringNoInit(src.len)
|
when declared(newObjRC1) and not defined(gcRegions):
|
||||||
result.len = src.len
|
var s = src.len
|
||||||
copyMem(addr(result.data), addr(src.data), src.len + 1)
|
if s < 7: s = 7
|
||||||
sysAssert((seqShallowFlag and result.reserved) == 0, "copyStringRC1")
|
result = cast[NimString](newObjRC1(addr(strDesc), sizeof(TGenericSeq) +
|
||||||
when defined(nimShallowStrings):
|
s+1))
|
||||||
if (src.reserved and strlitFlag) != 0:
|
result.reserved = s
|
||||||
result.reserved = (result.reserved and not strlitFlag) or seqShallowFlag
|
when defined(gogc):
|
||||||
|
result.elemSize = 1
|
||||||
|
else:
|
||||||
|
result = rawNewStringNoInit(src.len)
|
||||||
|
result.len = src.len
|
||||||
|
copyMem(addr(result.data), addr(src.data), src.len + 1)
|
||||||
|
sysAssert((seqShallowFlag and result.reserved) == 0, "copyStringRC1")
|
||||||
|
when defined(nimShallowStrings):
|
||||||
|
if (src.reserved and strlitFlag) != 0:
|
||||||
|
result.reserved = (result.reserved and not strlitFlag) or seqShallowFlag
|
||||||
|
|
||||||
proc copyDeepString(src: NimString): NimString {.inline.} =
|
proc copyDeepString(src: NimString): NimString {.inline.} =
|
||||||
if src != nil:
|
if src != nil:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue