File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,10 @@ func NewBTreeG[T any](less func(a, b T) bool) *BTreeG[T] {
5454func NewBTreeGOptions [T any ](less func (a , b T ) bool , opts Options ) * BTreeG [T ] {
5555 tr := new (BTreeG [T ])
5656 tr .isoid = newIsoID ()
57- tr .mu = new (sync.RWMutex )
5857 tr .locks = ! opts .NoLocks
58+ if tr .locks {
59+ tr .mu = new (sync.RWMutex )
60+ }
5961 tr .less = less
6062 tr .init (opts .Degree )
6163 return tr
@@ -1066,13 +1068,15 @@ func (tr *BTreeG[T]) Copy() *BTreeG[T] {
10661068}
10671069
10681070func (tr * BTreeG [T ]) IsoCopy () * BTreeG [T ] {
1071+ var mu * sync.RWMutex
10691072 if tr .lock (true ) {
1073+ mu = new (sync.RWMutex )
10701074 defer tr .unlock (true )
10711075 }
10721076 tr .isoid = newIsoID ()
10731077 tr2 := new (BTreeG [T ])
10741078 * tr2 = * tr
1075- tr2 .mu = new (sync. RWMutex )
1079+ tr2 .mu = mu
10761080 tr2 .isoid = newIsoID ()
10771081 return tr2
10781082}
You can’t perform that action at this time.
0 commit comments