File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,16 @@ impl<I: Iterator<Item=char>> Iterator for Decompositions<I> {
128
128
}
129
129
}
130
130
131
+ // We can assume here that, if `self.ready.end` is greater than zero,
132
+ // it's also greater than `self.ready.start`. That's because we only
133
+ // increment `self.ready.start` inside `increment_next_ready`, and
134
+ // whenever it reaches equality with `self.ready.end`, we reset both
135
+ // to zero, maintaining the invariant that:
136
+ // self.ready.start < self.ready.end || self.ready.end == self.ready.start == 0
137
+ //
138
+ // This less-than-obviously-safe implementation is chosen for performance,
139
+ // minimizing the number & complexity of branches in `next` in the common
140
+ // case of buffering then unbuffering a single character with each call.
131
141
let ( _, ch) = self . buffer [ self . ready . start ] ;
132
142
self . increment_next_ready ( ) ;
133
143
Some ( ch)
You can’t perform that action at this time.
0 commit comments