aboutsummaryrefslogtreecommitdiffstats
path: root/components/range/lib.rs
diff options
context:
space:
mode:
authorCristian Brinza <cristianb@gmail.com>2024-08-19 13:47:09 +0300
committerGitHub <noreply@github.com>2024-08-19 10:47:09 +0000
commit2a31fddc0b6f3ae89bd36cff3be1062e54c4a64c (patch)
treed4cb341b0a1f6c563b1128a63fbf1b02436ed7f3 /components/range/lib.rs
parentd59a7f62f8f49c810a6d42b154d39bb8440eb11e (diff)
downloadservo-2a31fddc0b6f3ae89bd36cff3be1062e54c4a64c.tar.gz
servo-2a31fddc0b6f3ae89bd36cff3be1062e54c4a64c.zip
Refactor `GlyphStore::iter_glyphs_for_byte_range` without recursion (#33074)
* Implement DoubleEndedIterator for EachIndex Signed-off-by: crbrz <cristianb@gmail.com> * Refactor GlyphStore::iter_glyphs_for_byte_range without recursion Signed-off-by: crbrz <cristianb@gmail.com> * Update WPT result Signed-off-by: crbrz <cristianb@gmail.com> * Update WPT legacy result Signed-off-by: crbrz <cristianb@gmail.com> --------- Signed-off-by: crbrz <cristianb@gmail.com>
Diffstat (limited to 'components/range/lib.rs')
-rw-r--r--components/range/lib.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/components/range/lib.rs b/components/range/lib.rs
index 8c5ca095f53..24c7231946c 100644
--- a/components/range/lib.rs
+++ b/components/range/lib.rs
@@ -193,6 +193,19 @@ impl<I: RangeIndex> Iterator for EachIndex<I> {
}
}
+impl<I: RangeIndex> DoubleEndedIterator for EachIndex<I> {
+ #[inline]
+ fn next_back(&mut self) -> Option<Self::Item> {
+ if self.start < self.stop {
+ let next = self.stop - I::one();
+ self.stop = next;
+ Some(next)
+ } else {
+ None
+ }
+ }
+}
+
impl<I: RangeIndex> Range<I> {
/// Create a new range from beginning and length offsets. This could be
/// denoted as `[begin, begin + length)`.