mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 12:45:27 +00:00
servo: Merge #6316 - Utilize if let
instead of match
in a few places (from frewsxcv:if-let); r=Ms2ger
Source-Repo: https://github.com/servo/servo Source-Revision: 6e0d0072b83bade910a6c2a0dee06d94f6f9fb17
This commit is contained in:
parent
e5a8317929
commit
a869e68c38
@ -140,9 +140,8 @@ impl Font {
|
||||
text: text.to_owned(),
|
||||
options: options.clone(),
|
||||
};
|
||||
match self.shape_cache.find(&lookup_key) {
|
||||
None => {}
|
||||
Some(glyphs) => return glyphs.clone(),
|
||||
if let Some(glyphs) = self.shape_cache.find(&lookup_key) {
|
||||
return glyphs.clone();
|
||||
}
|
||||
|
||||
let mut glyphs = GlyphStore::new(text.chars().count(),
|
||||
@ -159,12 +158,9 @@ impl Font {
|
||||
|
||||
fn make_shaper<'a>(&'a mut self, options: &ShapingOptions) -> &'a Shaper {
|
||||
// fast path: already created a shaper
|
||||
match self.shaper {
|
||||
Some(ref mut shaper) => {
|
||||
shaper.set_options(options);
|
||||
return shaper
|
||||
},
|
||||
None => {}
|
||||
if let Some(ref mut shaper) = self.shaper {
|
||||
shaper.set_options(options);
|
||||
return shaper
|
||||
}
|
||||
|
||||
let shaper = Shaper::new(self, options);
|
||||
|
@ -23,19 +23,15 @@ pub fn get_available_families<F>(mut callback: F) where F: FnMut(String) {
|
||||
pub fn get_variations_for_family<F>(family_name: &str, mut callback: F) where F: FnMut(String) {
|
||||
debug!("Looking for faces of family: {}", family_name);
|
||||
|
||||
let family_collection =
|
||||
core_text::font_collection::create_for_family(family_name);
|
||||
match family_collection {
|
||||
Some(family_collection) => {
|
||||
let family_descriptors = family_collection.get_descriptors();
|
||||
for descref in family_descriptors.iter() {
|
||||
let descref: CTFontDescriptorRef = unsafe { mem::transmute(descref) };
|
||||
let desc: CTFontDescriptor = unsafe { TCFType::wrap_under_get_rule(descref) };
|
||||
let postscript_name = desc.font_name();
|
||||
callback(postscript_name);
|
||||
}
|
||||
let family_collection = core_text::font_collection::create_for_family(family_name);
|
||||
if let Some(family_collection) = family_collection {
|
||||
let family_descriptors = family_collection.get_descriptors();
|
||||
for descref in family_descriptors.iter() {
|
||||
let descref: CTFontDescriptorRef = unsafe { mem::transmute(descref) };
|
||||
let desc: CTFontDescriptor = unsafe { TCFType::wrap_under_get_rule(descref) };
|
||||
let postscript_name = desc.font_name();
|
||||
callback(postscript_name);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user