Open lmittmann opened 8 months ago
This is not specific to [N]byte
but also []byte
.
As a point of semantic correctness we have to descend into each individual byte
element if there were any options that are possibly applicable. However, we could short-circuit the evaluation if we detect that no option could possibly be applicable. Note that if the caller passes in any cmp.FilterPath
options, then we cannot do the short-circuit since this option is Turing complete and we cannot prove that it wouldn't match on individual byte
values.
I ran into an issue where the comparison of a struct type containing lots of arrays took super long. After adding
cmpopts.EquateComparable
to the check the comparison is more than 10x faster. I think it should be okay to compare arrays of basic types (e.g.[32]byte
) using==
by default.Example Benchmark:
Results: