Skip to content

Commit

Permalink
DeepCopy -> unrefCopy
Browse files Browse the repository at this point in the history
  • Loading branch information
jaekwon committed Jan 4, 2024
1 parent de2a233 commit 5e2948a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions gnovm/pkg/gnolang/uverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func UverseNode() *PackageNode {
list := make([]TypedValue, argsl)
if 0 < argsl {
for i := 0; i < argsl; i++ {
list[i] = argsb.List[argso+i].DeepCopy(m.Alloc, m.Store)
list[i] = argsb.List[argso+i].unrefCopy(m.Alloc, m.Store)
}
}
m.PushValue(TypedValue{
Expand Down Expand Up @@ -296,9 +296,9 @@ func UverseNode() *PackageNode {
if argsb.Data == nil {
for i := 0; i < argsl; i++ {
oldElem := list[xvo+xvl+i]
// DeepCopy will resolve references and copy their values to prevent
// reference copying rather than copying the underlying values.
newElem := argsb.List[argso+i].DeepCopy(m.Alloc, m.Store)
// unrefCopy will resolve references and copy their values
// to copy by value rather than by reference.
newElem := argsb.List[argso+i].unrefCopy(m.Alloc, m.Store)
list[xvo+xvl+i] = newElem

m.Realm.DidUpdate(
Expand Down Expand Up @@ -376,7 +376,7 @@ func UverseNode() *PackageNode {
if 0 < xvl {
if xvb.Data == nil {
for i := 0; i < xvl; i++ {
list[i] = xvb.List[xvo+i].DeepCopy(m.Alloc, m.Store)
list[i] = xvb.List[xvo+i].unrefCopy(m.Alloc, m.Store)
}
} else {
panic("should not happen")
Expand All @@ -392,7 +392,7 @@ func UverseNode() *PackageNode {
if 0 < argsl {
if argsb.Data == nil {
for i := 0; i < argsl; i++ {
list[xvl+i] = argsb.List[argso+i].DeepCopy(m.Alloc, m.Store)
list[xvl+i] = argsb.List[argso+i].unrefCopy(m.Alloc, m.Store)
}
} else {
copyDataToList(
Expand Down Expand Up @@ -473,7 +473,7 @@ func UverseNode() *PackageNode {
list := make([]TypedValue, listLen)
if 0 < xvl {
for i := 0; i < listLen; i++ {
list[i] = xvb.List[xvo+i].DeepCopy(m.Alloc, m.Store)
list[i] = xvb.List[xvo+i].unrefCopy(m.Alloc, m.Store)
}
}
if 0 < argsl {
Expand Down
4 changes: 2 additions & 2 deletions gnovm/pkg/gnolang/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -1010,9 +1010,9 @@ func (tv TypedValue) Copy(alloc *Allocator) (cp TypedValue) {
return
}

// DeepCopy makes of copy of the underlying value in the case of reference values.
// unrefCopy makes a copy of the underlying value in the case of reference values.
// It copies other values as expected using the normal Copy method.
func (tv TypedValue) DeepCopy(alloc *Allocator, store Store) (cp TypedValue) {
func (tv TypedValue) unrefCopy(alloc *Allocator, store Store) (cp TypedValue) {
switch tv.V.(type) {
case RefValue:
cp.T = tv.T
Expand Down

0 comments on commit 5e2948a

Please sign in to comment.