File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -606,12 +606,28 @@ class MetadataCacheKey {
606
606
// Compare the hashes.
607
607
if (hash () != rhs.hash ()) return false ;
608
608
609
+ // Fast path the case where they're bytewise identical. That's nearly always
610
+ // the case if the hashes are the same, and we can skip the slower deep
611
+ // comparison.
612
+ auto *adata = begin ();
613
+ auto *bdata = rhs.begin ();
614
+
615
+ auto asize = (uintptr_t )end () - (uintptr_t )adata;
616
+ auto bsize = (uintptr_t )rhs.end () - (uintptr_t )bdata;
617
+
618
+ // If sizes don't match, they can never be equal.
619
+ if (asize != bsize)
620
+ return false ;
621
+
622
+ // If sizes match, see if the bytes match. If they do, then the contents
623
+ // must necessarily match. Otherwise do a deep comparison.
624
+ if (memcmp (adata, bdata, asize) == 0 )
625
+ return true ;
626
+
609
627
// Compare the layouts.
610
628
if (Layout != rhs.Layout ) return false ;
611
629
612
630
// Compare the content.
613
- auto *adata = begin ();
614
- auto *bdata = rhs.begin ();
615
631
const uintptr_t *packCounts = reinterpret_cast <const uintptr_t *>(adata);
616
632
617
633
unsigned argIdx = 0 ;
You can’t perform that action at this time.
0 commit comments