mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Use Option functions to make logic clearer
This commit is contained in:
parent
a351710004
commit
61216c301d
1 changed files with 24 additions and 36 deletions
|
@ -355,15 +355,13 @@ impl<'a> DetailedGlyphStore {
|
|||
detail_offset: 0, // unused
|
||||
};
|
||||
|
||||
match self.detail_lookup.as_slice().binary_search_index(&key) {
|
||||
None => fail!("Invalid index not found in detailed glyph lookup table!"),
|
||||
Some(i) => {
|
||||
let i = self.detail_lookup.as_slice().binary_search_index(&key)
|
||||
.expect("Invalid index not found in detailed glyph lookup table!");
|
||||
|
||||
assert!(i + (count as uint) <= self.detail_buffer.len());
|
||||
// return a slice into the buffer
|
||||
self.detail_buffer.slice(i, i + count as uint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_detailed_glyph_with_index(&'a self,
|
||||
entry_offset: CharIndex,
|
||||
|
@ -377,13 +375,11 @@ impl<'a> DetailedGlyphStore {
|
|||
detail_offset: 0, // unused
|
||||
};
|
||||
|
||||
match self.detail_lookup.as_slice().binary_search_index(&key) {
|
||||
None => fail!("Invalid index not found in detailed glyph lookup table!"),
|
||||
Some(i) => {
|
||||
let i = self.detail_lookup.as_slice().binary_search_index(&key)
|
||||
.expect("Invalid index not found in detailed glyph lookup table!");
|
||||
|
||||
assert!(i + (detail_offset as uint) < self.detail_buffer.len());
|
||||
self.detail_buffer.get(i+(detail_offset as uint))
|
||||
}
|
||||
}
|
||||
self.detail_buffer.get(i + (detail_offset as uint))
|
||||
}
|
||||
|
||||
fn ensure_sorted(&mut self) {
|
||||
|
@ -432,15 +428,10 @@ impl GlyphData {
|
|||
cluster_start: bool,
|
||||
ligature_start: bool)
|
||||
-> GlyphData {
|
||||
let offset = match offset {
|
||||
None => Zero::zero(),
|
||||
Some(o) => o,
|
||||
};
|
||||
|
||||
GlyphData {
|
||||
id: id,
|
||||
advance: advance,
|
||||
offset: offset,
|
||||
offset: offset.unwrap_or(Zero::zero()),
|
||||
is_missing: is_missing,
|
||||
cluster_start: cluster_start,
|
||||
ligature_start: ligature_start,
|
||||
|
@ -744,8 +735,7 @@ impl<'a> Iterator<(CharIndex, GlyphInfo<'a>)> for GlyphIterator<'a> {
|
|||
self.next_glyph_range()
|
||||
} else {
|
||||
// No glyph range. Look at next character.
|
||||
match self.char_range.next() {
|
||||
Some(i) => {
|
||||
self.char_range.next().and_then(|i| {
|
||||
self.char_index = i;
|
||||
assert!(i < self.store.char_len());
|
||||
let entry = self.store.entry_buffer.get(i.to_uint());
|
||||
|
@ -755,9 +745,7 @@ impl<'a> Iterator<(CharIndex, GlyphInfo<'a>)> for GlyphIterator<'a> {
|
|||
// Fall back to the slow path.
|
||||
self.next_complex_glyph(entry, i)
|
||||
}
|
||||
},
|
||||
None => None
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue