File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ impl fmt::Debug for Item {
79
79
}
80
80
81
81
/// Extra per-location state.
82
- #[ derive( Clone , Debug , PartialEq , Eq ) ]
82
+ #[ derive( Clone , Debug , Eq ) ]
83
83
pub struct Stack {
84
84
/// Used *mostly* as a stack; never empty.
85
85
/// Invariants:
@@ -88,6 +88,18 @@ pub struct Stack {
88
88
borrows : Vec < Item > ,
89
89
}
90
90
91
+ /// This implementation is primarily used when attempting to merge borrow stacks for adjacent
92
+ /// bytes. For adjacent stacks, when the stacks differ at all, they tend to differ either in
93
+ /// length or at the end of the borrows array. Iterating in reverse returns faster for `Stack`s
94
+ /// that are not equal.
95
+ impl PartialEq for Stack {
96
+ fn eq ( & self , other : & Self ) -> bool {
97
+ let Stack { borrows : lhs } = self ;
98
+ let Stack { borrows : rhs } = other;
99
+ lhs. len ( ) == rhs. len ( ) && lhs. iter ( ) . rev ( ) . zip ( rhs. iter ( ) . rev ( ) ) . all ( |( l, r) | l == r)
100
+ }
101
+ }
102
+
91
103
/// Extra per-allocation state.
92
104
#[ derive( Clone , Debug ) ]
93
105
pub struct Stacks {
You can’t perform that action at this time.
0 commit comments