mirror of
https://github.com/servo/servo.git
synced 2025-06-25 01:24:37 +01:00
~[] to std::vec::Vec in gfx/text/glyph.rs
This commit is contained in:
parent
f219dbeb6f
commit
f32d1f007f
1 changed files with 9 additions and 9 deletions
|
@ -300,18 +300,18 @@ impl Ord for DetailedGlyphRecord {
|
||||||
struct DetailedGlyphStore {
|
struct DetailedGlyphStore {
|
||||||
// TODO(pcwalton): Allocation of this buffer is expensive. Consider a small-vector
|
// TODO(pcwalton): Allocation of this buffer is expensive. Consider a small-vector
|
||||||
// optimization.
|
// optimization.
|
||||||
detail_buffer: ~[DetailedGlyph],
|
detail_buffer: Vec<DetailedGlyph>,
|
||||||
// TODO(pcwalton): Allocation of this buffer is expensive. Consider a small-vector
|
// TODO(pcwalton): Allocation of this buffer is expensive. Consider a small-vector
|
||||||
// optimization.
|
// optimization.
|
||||||
detail_lookup: ~[DetailedGlyphRecord],
|
detail_lookup: Vec<DetailedGlyphRecord>,
|
||||||
lookup_is_sorted: bool,
|
lookup_is_sorted: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DetailedGlyphStore {
|
impl<'a> DetailedGlyphStore {
|
||||||
fn new() -> DetailedGlyphStore {
|
fn new() -> DetailedGlyphStore {
|
||||||
DetailedGlyphStore {
|
DetailedGlyphStore {
|
||||||
detail_buffer: ~[], // TODO: default size?
|
detail_buffer: Vec::new(), // TODO: default size?
|
||||||
detail_lookup: ~[],
|
detail_lookup: Vec::new(),
|
||||||
lookup_is_sorted: false
|
lookup_is_sorted: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,7 @@ impl<'a> DetailedGlyphStore {
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: This is a workaround for borrow of self.detail_lookup not getting inferred.
|
// FIXME: This is a workaround for borrow of self.detail_lookup not getting inferred.
|
||||||
let records : &[DetailedGlyphRecord] = self.detail_lookup;
|
let records : &[DetailedGlyphRecord] = self.detail_lookup.as_slice();
|
||||||
match records.binary_search_index(&key) {
|
match records.binary_search_index(&key) {
|
||||||
None => fail!("Invalid index not found in detailed glyph lookup table!"),
|
None => fail!("Invalid index not found in detailed glyph lookup table!"),
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
|
@ -383,12 +383,12 @@ impl<'a> DetailedGlyphStore {
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: This is a workaround for borrow of self.detail_lookup not getting inferred.
|
// FIXME: This is a workaround for borrow of self.detail_lookup not getting inferred.
|
||||||
let records: &[DetailedGlyphRecord] = self.detail_lookup;
|
let records: &[DetailedGlyphRecord] = self.detail_lookup.as_slice();
|
||||||
match records.binary_search_index(&key) {
|
match records.binary_search_index(&key) {
|
||||||
None => fail!("Invalid index not found in detailed glyph lookup table!"),
|
None => fail!("Invalid index not found in detailed glyph lookup table!"),
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
assert!(i + (detail_offset as uint) < self.detail_buffer.len());
|
assert!(i + (detail_offset as uint) < self.detail_buffer.len());
|
||||||
&self.detail_buffer[i+(detail_offset as uint)]
|
self.detail_buffer.get(i+(detail_offset as uint))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,9 +403,9 @@ impl<'a> DetailedGlyphStore {
|
||||||
// immutable locations thus don't play well with freezing.
|
// immutable locations thus don't play well with freezing.
|
||||||
|
|
||||||
// Thar be dragons here. You have been warned. (Tips accepted.)
|
// Thar be dragons here. You have been warned. (Tips accepted.)
|
||||||
let mut unsorted_records: ~[DetailedGlyphRecord] = ~[];
|
let mut unsorted_records: Vec<DetailedGlyphRecord> = Vec::new();
|
||||||
mem::swap(&mut self.detail_lookup, &mut unsorted_records);
|
mem::swap(&mut self.detail_lookup, &mut unsorted_records);
|
||||||
let mut mut_records : ~[DetailedGlyphRecord] = unsorted_records;
|
let mut mut_records : Vec<DetailedGlyphRecord> = unsorted_records;
|
||||||
mut_records.sort_by(|a, b| {
|
mut_records.sort_by(|a, b| {
|
||||||
if a < b {
|
if a < b {
|
||||||
Less
|
Less
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue