File tree 1 file changed +12
-1
lines changed
1 file changed +12
-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,17 @@ 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
+ self . borrows . len ( ) == other. borrows . len ( )
98
+ && self . borrows . iter ( ) . rev ( ) . zip ( other. borrows . iter ( ) . rev ( ) ) . all ( |( s, o) | s == o)
99
+ }
100
+ }
101
+
91
102
/// Extra per-allocation state.
92
103
#[ derive( Clone , Debug ) ]
93
104
pub struct Stacks {
You can’t perform that action at this time.
0 commit comments