mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Remove some as_slice calls.
This commit is contained in:
parent
4ee89363fb
commit
6a55ae06d7
34 changed files with 79 additions and 79 deletions
|
@ -32,7 +32,7 @@ struct BufferKey([usize; 2]);
|
|||
impl Hash for BufferKey {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
let BufferKey(ref bytes) = *self;
|
||||
bytes.as_slice().hash(state);
|
||||
bytes.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ use platform::font_list::get_variations_for_family;
|
|||
use platform::font_list::get_last_resort_font_families;
|
||||
use platform::font_context::FontContextHandle;
|
||||
|
||||
use collections::str::Str;
|
||||
use font_template::{FontTemplate, FontTemplateDescriptor};
|
||||
use net_traits::{ResourceTask, load_whole_resource};
|
||||
use platform::font_template::FontTemplateData;
|
||||
|
@ -106,7 +105,7 @@ fn add_generic_font(generic_fonts: &mut HashMap<LowercaseString, LowercaseString
|
|||
generic_name: &str, mapped_name: &str) {
|
||||
let opt_system_default = get_system_default_family(generic_name);
|
||||
let family_name = match opt_system_default {
|
||||
Some(system_default) => LowercaseString::new(system_default.as_slice()),
|
||||
Some(system_default) => LowercaseString::new(&system_default),
|
||||
None => LowercaseString::new(mapped_name),
|
||||
};
|
||||
generic_fonts.insert(LowercaseString::new(generic_name), family_name);
|
||||
|
@ -119,7 +118,7 @@ impl FontCache {
|
|||
|
||||
match msg {
|
||||
Command::GetFontTemplate(family, descriptor, result) => {
|
||||
let family = LowercaseString::new(family.as_slice());
|
||||
let family = LowercaseString::new(&family);
|
||||
let maybe_font_template = self.get_font_template(&family, &descriptor);
|
||||
result.send(Reply::GetFontTemplateReply(maybe_font_template)).unwrap();
|
||||
}
|
||||
|
@ -128,7 +127,7 @@ impl FontCache {
|
|||
result.send(Reply::GetFontTemplateReply(Some(font_template))).unwrap();
|
||||
}
|
||||
Command::AddWebFont(family_name, src, result) => {
|
||||
let family_name = LowercaseString::new(family_name.as_slice());
|
||||
let family_name = LowercaseString::new(&family_name);
|
||||
if !self.web_families.contains_key(&family_name) {
|
||||
let family = FontFamily::new();
|
||||
self.web_families.insert(family_name.clone(), family);
|
||||
|
@ -141,7 +140,7 @@ impl FontCache {
|
|||
match maybe_resource {
|
||||
Ok((_, bytes)) => {
|
||||
let family = &mut self.web_families[family_name];
|
||||
family.add_template(url.to_string().as_slice(), Some(bytes));
|
||||
family.add_template(&url.to_string(), Some(bytes));
|
||||
},
|
||||
Err(_) => {
|
||||
debug!("Failed to load web font: family={:?} url={}", family_name, url);
|
||||
|
@ -150,8 +149,8 @@ impl FontCache {
|
|||
}
|
||||
Source::Local(ref local_family_name) => {
|
||||
let family = &mut self.web_families[family_name];
|
||||
get_variations_for_family(local_family_name.as_slice(), |path| {
|
||||
family.add_template(path.as_slice(), None);
|
||||
get_variations_for_family(&local_family_name, |path| {
|
||||
family.add_template(&path, None);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +167,7 @@ impl FontCache {
|
|||
fn refresh_local_families(&mut self) {
|
||||
self.local_families.clear();
|
||||
get_available_families(|family_name| {
|
||||
let family_name = LowercaseString::new(family_name.as_slice());
|
||||
let family_name = LowercaseString::new(&family_name);
|
||||
if !self.local_families.contains_key(&family_name) {
|
||||
let family = FontFamily::new();
|
||||
self.local_families.insert(family_name, family);
|
||||
|
@ -188,12 +187,12 @@ impl FontCache {
|
|||
// TODO(Issue #188): look up localized font family names if canonical name not found
|
||||
// look up canonical name
|
||||
if self.local_families.contains_key(family_name) {
|
||||
debug!("FontList: Found font family with name={}", family_name.as_slice());
|
||||
debug!("FontList: Found font family with name={}", &**family_name);
|
||||
let s = &mut self.local_families[*family_name];
|
||||
|
||||
if s.templates.len() == 0 {
|
||||
get_variations_for_family(family_name.as_slice(), |path| {
|
||||
s.add_template(path.as_slice(), None);
|
||||
get_variations_for_family(&family_name, |path| {
|
||||
s.add_template(&path, None);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -206,7 +205,7 @@ impl FontCache {
|
|||
|
||||
None
|
||||
} else {
|
||||
debug!("FontList: Couldn't find font family with name={}", family_name.as_slice());
|
||||
debug!("FontList: Couldn't find font family with name={}", &**family_name);
|
||||
None
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +236,7 @@ impl FontCache {
|
|||
let last_resort = get_last_resort_font_families();
|
||||
|
||||
for family in last_resort.iter() {
|
||||
let family = LowercaseString::new(family.as_slice());
|
||||
let family = LowercaseString::new(family);
|
||||
let maybe_font_in_family = self.find_font_in_local_family(&family, desc);
|
||||
if maybe_font_in_family.is_some() {
|
||||
return maybe_font_in_family.unwrap();
|
||||
|
|
|
@ -164,7 +164,7 @@ impl FontContext {
|
|||
// GWTODO: Check on real pages if this is faster as Vec() or HashMap().
|
||||
let mut cache_hit = false;
|
||||
for cached_font_entry in self.layout_font_cache.iter() {
|
||||
if cached_font_entry.family.as_slice() == family.name() {
|
||||
if cached_font_entry.family == family.name() {
|
||||
match cached_font_entry.font {
|
||||
None => {
|
||||
cache_hit = true;
|
||||
|
|
|
@ -158,7 +158,7 @@ impl FontTemplate {
|
|||
}
|
||||
|
||||
assert!(self.strong_ref.is_none());
|
||||
let template_data = Arc::new(FontTemplateData::new(self.identifier.as_slice(), None));
|
||||
let template_data = Arc::new(FontTemplateData::new(&self.identifier, None));
|
||||
self.weak_ref = Some(template_data.downgrade());
|
||||
template_data
|
||||
}
|
||||
|
|
|
@ -133,8 +133,8 @@ impl<'a> PaintContext<'a> {
|
|||
image_rendering: image_rendering::T) {
|
||||
let size = Size2D(image.width as i32, image.height as i32);
|
||||
let (pixel_width, pixels, source_format) = match image.pixels {
|
||||
PixelsByColorType::RGBA8(ref pixels) => (4, pixels.as_slice(), SurfaceFormat::B8G8R8A8),
|
||||
PixelsByColorType::K8(ref pixels) => (1, pixels.as_slice(), SurfaceFormat::A8),
|
||||
PixelsByColorType::RGBA8(ref pixels) => (4, pixels, SurfaceFormat::B8G8R8A8),
|
||||
PixelsByColorType::K8(ref pixels) => (1, pixels, SurfaceFormat::A8),
|
||||
PixelsByColorType::RGB8(_) => panic!("RGB8 color type not supported"),
|
||||
PixelsByColorType::KA8(_) => panic!("KA8 color type not supported"),
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ pub fn get_variations_for_family<F>(family_name: &str, mut callback: F) where F:
|
|||
debug!("Looking for faces of family: {}", family_name);
|
||||
|
||||
let family_collection =
|
||||
core_text::font_collection::create_for_family(family_name.as_slice());
|
||||
core_text::font_collection::create_for_family(family_name);
|
||||
match family_collection {
|
||||
Some(family_collection) => {
|
||||
let family_descriptors = family_collection.get_descriptors();
|
||||
|
|
|
@ -26,7 +26,7 @@ impl FontTemplateData {
|
|||
pub fn new(identifier: &str, font_data: Option<Vec<u8>>) -> FontTemplateData {
|
||||
let ctfont = match font_data {
|
||||
Some(ref bytes) => {
|
||||
let fontprov = CGDataProvider::from_buffer(bytes.as_slice());
|
||||
let fontprov = CGDataProvider::from_buffer(bytes);
|
||||
let cgfont_result = CGFont::from_data_provider(fontprov);
|
||||
match cgfont_result {
|
||||
Ok(cgfont) => Some(core_text::font::new_from_CGFont(&cgfont, 0.0)),
|
||||
|
@ -34,7 +34,7 @@ impl FontTemplateData {
|
|||
}
|
||||
},
|
||||
None => {
|
||||
Some(core_text::font::new_from_name(identifier.as_slice(), 0.0).unwrap())
|
||||
Some(core_text::font::new_from_name(&identifier, 0.0).unwrap())
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -359,7 +359,7 @@ impl<'a> DetailedGlyphStore {
|
|||
detail_offset: 0, // unused
|
||||
};
|
||||
|
||||
let i = (&*self.detail_lookup).binary_search_index(&key)
|
||||
let i = self.detail_lookup.binary_search_index(&key)
|
||||
.expect("Invalid index not found in detailed glyph lookup table!");
|
||||
|
||||
assert!(i + (count as usize) <= self.detail_buffer.len());
|
||||
|
@ -379,7 +379,7 @@ impl<'a> DetailedGlyphStore {
|
|||
detail_offset: 0, // unused
|
||||
};
|
||||
|
||||
let i = self.detail_lookup.as_slice().binary_search_index(&key)
|
||||
let i = self.detail_lookup.binary_search_index(&key)
|
||||
.expect("Invalid index not found in detailed glyph lookup table!");
|
||||
|
||||
assert!(i + (detail_offset as usize) < self.detail_buffer.len());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue