Skip to content

Commit 8bff488

Browse files
committed
Use EqualsUsing recursively
Currently, EqualsUsing recurses with Equals, which loses the allocator that you're using, defeating the whole point. Address that in all places I could find. Doesn't affect anything yet since it's not used beside the benchmark: ``` name old time/op new time/op delta Equals/pod.yaml/Equals-8 19.7µs ± 5% 19.3µs ± 2% ~ (p=0.222 n=5+5) Equals/pod.yaml/EqualsUsingFreelist-8 19.4µs ± 4% 16.5µs ± 3% -14.95% (p=0.008 n=5+5) Equals/endpoints.yaml/Equals-8 982µs ± 3% 977µs ± 5% ~ (p=0.548 n=5+5) Equals/endpoints.yaml/EqualsUsingFreelist-8 970µs ± 5% 872µs ± 6% -10.02% (p=0.008 n=5+5) Equals/list.yaml/Equals-8 4.02µs ± 1% 4.20µs ± 8% +4.37% (p=0.008 n=5+5) Equals/list.yaml/EqualsUsingFreelist-8 4.03µs ± 4% 3.42µs ± 4% -15.15% (p=0.008 n=5+5) Equals/node.yaml/Equals-8 42.0µs ± 3% 40.2µs ± 2% -4.33% (p=0.016 n=5+5) Equals/node.yaml/EqualsUsingFreelist-8 40.3µs ± 2% 34.4µs ± 5% -14.55% (p=0.008 n=5+5) Equals/prometheus-crd.yaml/Equals-8 340µs ± 2% 347µs ± 2% ~ (p=0.151 n=5+5) Equals/prometheus-crd.yaml/EqualsUsingFreelist-8 352µs ± 3% 301µs ± 9% -14.57% (p=0.008 n=5+5) name old alloc/op new alloc/op delta Equals/pod.yaml/Equals-8 3.59kB ± 0% 4.36kB ± 0% +21.38% (p=0.008 n=5+5) Equals/pod.yaml/EqualsUsingFreelist-8 3.58kB ± 0% 2.18kB ± 0% -38.93% (p=0.008 n=5+5) Equals/endpoints.yaml/Equals-8 113kB ± 0% 161kB ± 0% +42.63% (p=0.029 n=4+4) Equals/endpoints.yaml/EqualsUsingFreelist-8 113kB ± 0% 96kB ± 0% -14.53% (p=0.008 n=5+5) Equals/list.yaml/Equals-8 1.02kB ± 0% 1.28kB ± 0% +25.98% (p=0.008 n=5+5) Equals/list.yaml/EqualsUsingFreelist-8 1.00kB ± 0% 0.67kB ± 0% -32.80% (p=0.008 n=5+5) Equals/node.yaml/Equals-8 9.25kB ± 0% 10.64kB ± 0% +15.05% (p=0.008 n=5+5) Equals/node.yaml/EqualsUsingFreelist-8 9.23kB ± 0% 4.94kB ± 0% -46.45% (p=0.008 n=5+5) Equals/prometheus-crd.yaml/Equals-8 60.7kB ± 0% 79.9kB ± 0% +31.69% (p=0.016 n=4+5) Equals/prometheus-crd.yaml/EqualsUsingFreelist-8 60.6kB ± 0% 44.1kB ± 0% ~ (p=0.079 n=4+5) name old allocs/op new allocs/op delta Equals/pod.yaml/Equals-8 159 ± 0% 159 ± 0% ~ (all equal) Equals/pod.yaml/EqualsUsingFreelist-8 158 ± 0% 59 ± 0% -62.66% (p=0.008 n=5+5) Equals/endpoints.yaml/Equals-8 6.04k ± 0% 6.04k ± 0% ~ (all equal) Equals/endpoints.yaml/EqualsUsingFreelist-8 6.04k ± 0% 2.01k ± 0% -66.63% (p=0.008 n=5+5) Equals/list.yaml/Equals-8 47.0 ± 0% 47.0 ± 0% ~ (all equal) Equals/list.yaml/EqualsUsingFreelist-8 46.0 ± 0% 17.0 ± 0% -63.04% (p=0.008 n=5+5) Equals/node.yaml/Equals-8 384 ± 0% 384 ± 0% ~ (all equal) Equals/node.yaml/EqualsUsingFreelist-8 383 ± 0% 148 ± 0% -61.36% (p=0.008 n=5+5) Equals/prometheus-crd.yaml/Equals-8 2.96k ± 0% 2.96k ± 0% ~ (all equal) Equals/prometheus-crd.yaml/EqualsUsingFreelist-8 2.96k ± 0% 1.04k ± 0% -64.87% (p=0.008 n=5+5) ```
1 parent 758c177 commit 8bff488

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

value/mapreflect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (r mapReflect) EqualsUsing(a Allocator, m Map) bool {
136136
if !ok {
137137
return false
138138
}
139-
return Equals(vr.mustReuse(lhsVal, entry, nil, nil), value)
139+
return EqualsUsing(a, vr.mustReuse(lhsVal, entry, nil, nil), value)
140140
})
141141
}
142142

value/mapunstructured.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ func (m mapUnstructuredInterface) EqualsUsing(a Allocator, other Map) bool {
8888
}
8989
vv := a.allocValueUnstructured()
9090
defer a.Free(vv)
91-
return other.Iterate(func(key string, value Value) bool {
91+
return other.IterateUsing(a, func(key string, value Value) bool {
9292
lhsVal, ok := m[key]
9393
if !ok {
9494
return false
9595
}
96-
return Equals(vv.reuse(lhsVal), value)
96+
return EqualsUsing(a, vv.reuse(lhsVal), value)
9797
})
9898
}
9999

@@ -168,12 +168,12 @@ func (m mapUnstructuredString) EqualsUsing(a Allocator, other Map) bool {
168168
}
169169
vv := a.allocValueUnstructured()
170170
defer a.Free(vv)
171-
return other.Iterate(func(key string, value Value) bool {
171+
return other.IterateUsing(a, func(key string, value Value) bool {
172172
lhsVal, ok := m[key]
173173
if !ok {
174174
return false
175175
}
176-
return Equals(vv.reuse(lhsVal), value)
176+
return EqualsUsing(a, vv.reuse(lhsVal), value)
177177
})
178178
}
179179

0 commit comments

Comments
 (0)