зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #18494 - Implement `size_hint` for more iterators (from frewsxcv:frewsxcv-size-hint); r=jdm
``` implement size hint for more iterators because why not we like fast things ``` Source-Repo: https://github.com/servo/servo Source-Revision: bb2030a49314433c1b31f853e4fa50afa241b596 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : fb164a6e8e51ebba14d97ee7600567b3b517dc30
This commit is contained in:
Родитель
4e26d7c8e5
Коммит
063db35806
|
@ -765,6 +765,10 @@ impl<'a> Iterator for AbsoluteDescendantIter<'a> {
|
||||||
fn next(&mut self) -> Option<&'a mut Flow> {
|
fn next(&mut self) -> Option<&'a mut Flow> {
|
||||||
self.iter.next().map(|info| FlowRef::deref_mut(&mut info.flow))
|
self.iter.next().map(|info| FlowRef::deref_mut(&mut info.flow))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
self.iter.size_hint()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type AbsoluteDescendantOffsetIter<'a> = Zip<AbsoluteDescendantIter<'a>, IterMut<'a, Au>>;
|
pub type AbsoluteDescendantOffsetIter<'a> = Zip<AbsoluteDescendantIter<'a>, IterMut<'a, Au>>;
|
||||||
|
|
|
@ -979,6 +979,10 @@ impl InlineFlow {
|
||||||
self.iter.next()
|
self.iter.next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
self.iter.size_hint()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the bidi embedding direction is opposite the layout direction, lay out this
|
// If the bidi embedding direction is opposite the layout direction, lay out this
|
||||||
|
|
|
@ -440,4 +440,12 @@ impl<I, J, K, T> Iterator for Choice3<I, J, K>
|
||||||
Choice3::Third(ref mut k) => k.next(),
|
Choice3::Third(ref mut k) => k.next(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
match *self {
|
||||||
|
Choice3::First(ref i) => i.size_hint(),
|
||||||
|
Choice3::Second(ref j) => j.size_hint(),
|
||||||
|
Choice3::Third(ref k) => k.size_hint(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -487,6 +487,10 @@ impl<I> Iterator for FragmentParsingResult<I>
|
||||||
next.remove_self();
|
next.remove_self();
|
||||||
Some(next)
|
Some(next)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
self.inner.size_hint()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(HeapSizeOf, JSTraceable, PartialEq)]
|
#[derive(HeapSizeOf, JSTraceable, PartialEq)]
|
||||||
|
|
|
@ -170,6 +170,10 @@ impl Iterator for EffectiveSources {
|
||||||
fn next(&mut self) -> Option<Source> {
|
fn next(&mut self) -> Option<Source> {
|
||||||
self.0.pop()
|
self.0.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
(self.0.len(), Some(self.0.len()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FontFaceRuleParser<'a, 'b: 'a> {
|
struct FontFaceRuleParser<'a, 'b: 'a> {
|
||||||
|
|
|
@ -99,6 +99,10 @@ impl<'a> Iterator for DeclarationImportanceIterator<'a> {
|
||||||
self.iter.next().map(|(decl, important)|
|
self.iter.next().map(|(decl, important)|
|
||||||
(decl, if important { Importance::Important } else { Importance::Normal }))
|
(decl, if important { Importance::Important } else { Importance::Normal }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
self.iter.size_hint()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DoubleEndedIterator for DeclarationImportanceIterator<'a> {
|
impl<'a> DoubleEndedIterator for DeclarationImportanceIterator<'a> {
|
||||||
|
|
|
@ -45,6 +45,10 @@ where
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
self.0.next().map(|entry| &entry.sheet)
|
self.0.next().map(|entry| &entry.sheet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
self.0.size_hint()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator over the flattened view of the stylesheet collections.
|
/// An iterator over the flattened view of the stylesheet collections.
|
||||||
|
|
|
@ -198,6 +198,10 @@ impl<'a, 'cx, 'cx_a: 'cx, S: ToComputedValue + 'a> Iterator for ComputedVecIter<
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
(self.values.len(), Some(self.values.len()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A trait to represent the conversion between computed and specified values.
|
/// A trait to represent the conversion between computed and specified values.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче