mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
Remove unused CharIndex field from GlyphIterator::Item
This commit is contained in:
parent
d3d1d15615
commit
5bacfe9db9
2 changed files with 8 additions and 10 deletions
|
@ -1791,7 +1791,7 @@ impl ScaledFontExtensionMethods for ScaledFont {
|
||||||
azglyphs.reserve(range.length().to_usize());
|
azglyphs.reserve(range.length().to_usize());
|
||||||
|
|
||||||
for slice in run.natural_word_slices_in_visual_order(range) {
|
for slice in run.natural_word_slices_in_visual_order(range) {
|
||||||
for (_i, glyph) in slice.glyphs.iter_glyphs_for_char_range(&slice.range) {
|
for glyph in slice.glyphs.iter_glyphs_for_char_range(&slice.range) {
|
||||||
let glyph_advance = glyph.advance();
|
let glyph_advance = glyph.advance();
|
||||||
let glyph_offset = glyph.offset().unwrap_or(Point2D::zero());
|
let glyph_offset = glyph.offset().unwrap_or(Point2D::zero());
|
||||||
let azglyph = struct__AzGlyph {
|
let azglyph = struct__AzGlyph {
|
||||||
|
|
|
@ -542,7 +542,7 @@ impl<'a> GlyphStore {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn advance_for_char_range_slow_path(&self, rang: &Range<CharIndex>) -> Au {
|
pub fn advance_for_char_range_slow_path(&self, rang: &Range<CharIndex>) -> Au {
|
||||||
self.iter_glyphs_for_char_range(rang)
|
self.iter_glyphs_for_char_range(rang)
|
||||||
.fold(Au(0), |advance, (_, glyph)| advance + glyph.advance())
|
.fold(Au(0), |advance, glyph| advance + glyph.advance())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -664,11 +664,10 @@ pub struct GlyphIterator<'a> {
|
||||||
impl<'a> GlyphIterator<'a> {
|
impl<'a> GlyphIterator<'a> {
|
||||||
// Slow path when there is a glyph range.
|
// Slow path when there is a glyph range.
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn next_glyph_range(&mut self) -> Option<(CharIndex, GlyphInfo<'a>)> {
|
fn next_glyph_range(&mut self) -> Option<GlyphInfo<'a>> {
|
||||||
match self.glyph_range.as_mut().unwrap().next() {
|
match self.glyph_range.as_mut().unwrap().next() {
|
||||||
Some(j) => {
|
Some(j) => {
|
||||||
Some((self.char_index,
|
Some(GlyphInfo::Detail(self.store, self.char_index, j.get() as u16 /* ??? */))
|
||||||
GlyphInfo::Detail(self.store, self.char_index, j.get() as u16 /* ??? */)))
|
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// No more glyphs for current character. Try to get another.
|
// No more glyphs for current character. Try to get another.
|
||||||
|
@ -680,8 +679,7 @@ impl<'a> GlyphIterator<'a> {
|
||||||
|
|
||||||
// Slow path when there is a complex glyph.
|
// Slow path when there is a complex glyph.
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn next_complex_glyph(&mut self, entry: &GlyphEntry, i: CharIndex)
|
fn next_complex_glyph(&mut self, entry: &GlyphEntry, i: CharIndex) -> Option<GlyphInfo<'a>> {
|
||||||
-> Option<(CharIndex, GlyphInfo<'a>)> {
|
|
||||||
let glyphs = self.store.detail_store.detailed_glyphs_for_entry(i, entry.glyph_count());
|
let glyphs = self.store.detail_store.detailed_glyphs_for_entry(i, entry.glyph_count());
|
||||||
self.glyph_range = Some(range::each_index(CharIndex(0), CharIndex(glyphs.len() as isize)));
|
self.glyph_range = Some(range::each_index(CharIndex(0), CharIndex(glyphs.len() as isize)));
|
||||||
self.next()
|
self.next()
|
||||||
|
@ -689,7 +687,7 @@ impl<'a> GlyphIterator<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for GlyphIterator<'a> {
|
impl<'a> Iterator for GlyphIterator<'a> {
|
||||||
type Item = (CharIndex, GlyphInfo<'a>);
|
type Item = GlyphInfo<'a>;
|
||||||
|
|
||||||
// I tried to start with something simpler and apply FlatMap, but the
|
// I tried to start with something simpler and apply FlatMap, but the
|
||||||
// inability to store free variables in the FlatMap struct was problematic.
|
// inability to store free variables in the FlatMap struct was problematic.
|
||||||
|
@ -698,7 +696,7 @@ impl<'a> Iterator for GlyphIterator<'a> {
|
||||||
// slow paths, which should not be inlined, are `next_glyph_range()` and
|
// slow paths, which should not be inlined, are `next_glyph_range()` and
|
||||||
// `next_complex_glyph()`.
|
// `next_complex_glyph()`.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn next(&mut self) -> Option<(CharIndex, GlyphInfo<'a>)> {
|
fn next(&mut self) -> Option<GlyphInfo<'a>> {
|
||||||
// Would use 'match' here but it borrows contents in a way that interferes with mutation.
|
// Would use 'match' here but it borrows contents in a way that interferes with mutation.
|
||||||
if self.glyph_range.is_some() {
|
if self.glyph_range.is_some() {
|
||||||
return self.next_glyph_range()
|
return self.next_glyph_range()
|
||||||
|
@ -717,7 +715,7 @@ impl<'a> Iterator for GlyphIterator<'a> {
|
||||||
debug_assert!(i < self.store.char_len());
|
debug_assert!(i < self.store.char_len());
|
||||||
let entry = self.store.entry_buffer[i.to_usize()];
|
let entry = self.store.entry_buffer[i.to_usize()];
|
||||||
if entry.is_simple() {
|
if entry.is_simple() {
|
||||||
Some((i, GlyphInfo::Simple(self.store, i)))
|
Some(GlyphInfo::Simple(self.store, i))
|
||||||
} else {
|
} else {
|
||||||
// Fall back to the slow path.
|
// Fall back to the slow path.
|
||||||
self.next_complex_glyph(&entry, i)
|
self.next_complex_glyph(&entry, i)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue