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
@@ -1090,13 +1092,15 @@ func (tr *BTreeG[T]) Copy() *BTreeG[T] {
10901092}
10911093
10921094func (tr * BTreeG [T ]) IsoCopy () * BTreeG [T ] {
1095+ var mu * sync.RWMutex
10931096 if tr .lock (true ) {
1097+ mu = new (sync.RWMutex )
10941098 defer tr .unlock (true )
10951099 }
10961100 tr .isoid = newIsoID ()
10971101 tr2 := new (BTreeG [T ])
10981102 * tr2 = * tr
1099- tr2 .mu = new (sync. RWMutex )
1103+ tr2 .mu = mu
11001104 tr2 .isoid = newIsoID ()
11011105 return tr2
11021106}
You can’t perform that action at this time.
0 commit comments