rename prepareStrMutation to prepareMutation (#17235)

* remove unnecessary when statement

* remove outdated codes

* rename prepareStrMutation to prepareMutation
This commit is contained in:
flywind 2021-03-03 08:08:52 +08:00 • committed by GitHub
commit a04c9d1f62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 10 deletions

View file

@ -676,25 +676,25 @@ moveMem(addr y[0], addr x[0], 3)
```
The program fails because we need to prepare a fresh copy for the variable `y`.
`prepareStrMutation` should be called before the address operation.
`prepareMutation` should be called before the address operation.
```nim
var x = "abc"
var y = x
prepareStrMutation(y)
prepareMutation(y)
moveMem(addr y[0], addr x[0], 3)
assert y == "abc"
```
Now `prepareStrMutation` solves the problem.
Now `prepareMutation` solves the problem.
It manually creates a fresh copy and makes the variable `y` mutable.
```nim
var x = "abc"
var y = x
prepareStrMutation(y)
prepareMutation(y)
moveMem(addr y[0], addr x[0], 3)
moveMem(addr y[0], addr x[0], 3)
moveMem(addr y[0], addr x[0], 3)