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] {
54
54
func NewBTreeGOptions [T any ](less func (a , b T ) bool , opts Options ) * BTreeG [T ] {
55
55
tr := new (BTreeG [T ])
56
56
tr .isoid = newIsoID ()
57
- tr .mu = new (sync.RWMutex )
58
57
tr .locks = ! opts .NoLocks
58
+ if tr .locks {
59
+ tr .mu = new (sync.RWMutex )
60
+ }
59
61
tr .less = less
60
62
tr .init (opts .Degree )
61
63
return tr
@@ -1066,13 +1068,15 @@ func (tr *BTreeG[T]) Copy() *BTreeG[T] {
1066
1068
}
1067
1069
1068
1070
func (tr * BTreeG [T ]) IsoCopy () * BTreeG [T ] {
1071
+ var mu * sync.RWMutex
1069
1072
if tr .lock (true ) {
1073
+ mu = new (sync.RWMutex )
1070
1074
defer tr .unlock (true )
1071
1075
}
1072
1076
tr .isoid = newIsoID ()
1073
1077
tr2 := new (BTreeG [T ])
1074
1078
* tr2 = * tr
1075
- tr2 .mu = new (sync. RWMutex )
1079
+ tr2 .mu = mu
1076
1080
tr2 .isoid = newIsoID ()
1077
1081
return tr2
1078
1082
}
You can’t perform that action at this time.
0 commit comments