Skip to content

Commit

Permalink
Pedantically rename Clone's receiver.
Browse files Browse the repository at this point in the history
It annoyed me that Clone's receiver was 'b' but the others were all 't'
:)
  • Loading branch information
gconnell committed Dec 17, 2016
1 parent 03716cb commit 316fb6d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions btree.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,25 +595,25 @@ type copyOnWriteContext struct {
}

// Clone clones the btree, lazily. Clone should not be called concurrently,
// but the original tree (b) and the new tree (b2) can be used concurrently
// but the original tree (t) and the new tree (t2) can be used concurrently
// once the Clone call completes.
//
// The internal tree structure of b is marked read-only and shared between b and
// b2. Writes to both b and b2 use copy-on-write logic, creating new nodes
// The internal tree structure of b is marked read-only and shared between t and
// t2. Writes to both t and t2 use copy-on-write logic, creating new nodes
// whenever one of b's original nodes would have been modified. Read operations
// should have no performance degredation. Write operations for both b and b2
// should have no performance degredation. Write operations for both t and t2
// will initially experience minor slow-downs caused by additional allocs and
// copies due to the aforementioned copy-on-write logic, but should converge to
// the original performance characteristics of the original tree.
func (b *BTree) Clone() (b2 *BTree) {
func (t *BTree) Clone() (t2 *BTree) {
// Create two entirely new copy-on-write contexts.
// This operation effectively creates three trees:
// the original, shared nodes (old b.cow)
// the new b.cow nodes
// the new out.cow nodes
cow1, cow2 := *b.cow, *b.cow
out := *b
b.cow = &cow1
cow1, cow2 := *t.cow, *t.cow
out := *t
t.cow = &cow1
out.cow = &cow2
return &out
}
Expand Down

0 comments on commit 316fb6d

Please sign in to comment.