rename prepareStrMutation to prepareMutation (#17235)
* remove unnecessary when statement * remove outdated codes * rename prepareStrMutation to prepareMutation
This commit is contained in:
parent
87897fa2d6
commit
a04c9d1f62
4 changed files with 10 additions and 10 deletions
|
|
@ -3122,14 +3122,14 @@ when not defined(createNimHcr) and not defined(nimscript):
|
|||
include nimhcr
|
||||
|
||||
when notJSnotNims and not defined(nimSeqsV2):
|
||||
proc prepareStrMutation*(s: var string) {.inline.} =
|
||||
proc prepareMutation*(s: var string) {.inline.} =
|
||||
## String literals (e.g. "abc", etc) in the ARC/ORC mode are "copy on write",
|
||||
## therefore you should call `prepareStrMutation` before modifying the strings
|
||||
## therefore you should call `prepareMutation` before modifying the strings
|
||||
## via `addr`.
|
||||
runnableExamples("--gc:arc"):
|
||||
var x = "abc"
|
||||
var y = "defgh"
|
||||
prepareStrMutation(y) # without this, you may get a `SIGBUS` or `SIGSEGV`
|
||||
prepareMutation(y) # without this, you may get a `SIGBUS` or `SIGSEGV`
|
||||
moveMem(addr y[0], addr x[0], x.len)
|
||||
assert y == "abcgh"
|
||||
discard
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue