diff options
author | Colin Cross <ccross@android.com> | 2024-02-01 14:31:47 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2024-02-02 15:57:26 -0800 |
commit | 1d82de2aabc986ad1fc85315167baa0f3343f8a7 (patch) | |
tree | b8a57eb18f56cac25c007973b46e6c1e0df618a2 | |
parent | 2ef2c356643239b4d42f03a5a95be2ebd7a026ef (diff) | |
download | blueprint-1d82de2aabc986ad1fc85315167baa0f3343f8a7.tar.gz |
Optimize blueprint.variationMap.equal
blueprint.variationMap.Equal was responsible for 11.5% of allocations
and 2.2% of allocated memory. reflect.DeepEquals is an expensive way
to compare a map. variationMap.subsetOf is already iterating through
the elements of the map to compare them, replace equal with a check that
the maps are the same length and then reuse subsetOf to check that the
have the same keys and values.
Test: SOONG_PROFILE_MEM=/tmp/mem.pprof m nothing
Change-Id: Ifb7cdf612e5455fd2f412488b7f94416c4e70c54
-rw-r--r-- | context.go | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -441,7 +441,10 @@ func (vm variationMap) subsetOf(other variationMap) bool { } func (vm variationMap) equal(other variationMap) bool { - return reflect.DeepEqual(vm, other) + if len(vm) != len(other) { + return false + } + return vm.subsetOf(other) } type singletonInfo struct { |