Use isize for CharIndex.

This commit is contained in:
Ms2ger 2015-04-02 14:24:23 +02:00
parent cd8c03bb49
commit 6d7dead4ef
2 changed files with 7 additions and 7 deletions

View file

@ -522,7 +522,7 @@ int_range_index! {
#[derive(RustcEncodable)] #[derive(RustcEncodable)]
#[doc = "An index that refers to a character in a text run. This could \ #[doc = "An index that refers to a character in a text run. This could \
point to the middle of a glyph."] point to the middle of a glyph."]
struct CharIndex(int) struct CharIndex(isize)
} }
impl<'a> GlyphStore { impl<'a> GlyphStore {
@ -540,7 +540,7 @@ impl<'a> GlyphStore {
} }
pub fn char_len(&self) -> CharIndex { pub fn char_len(&self) -> CharIndex {
CharIndex(self.entry_buffer.len() as int) CharIndex(self.entry_buffer.len() as isize)
} }
pub fn is_whitespace(&self) -> bool { pub fn is_whitespace(&self) -> bool {
@ -743,8 +743,8 @@ impl<'a> GlyphStore {
pub struct GlyphIterator<'a> { pub struct GlyphIterator<'a> {
store: &'a GlyphStore, store: &'a GlyphStore,
char_index: CharIndex, char_index: CharIndex,
char_range: EachIndex<int, CharIndex>, char_range: EachIndex<isize, CharIndex>,
glyph_range: Option<EachIndex<int, CharIndex>>, glyph_range: Option<EachIndex<isize, CharIndex>>,
} }
impl<'a> GlyphIterator<'a> { impl<'a> GlyphIterator<'a> {
@ -767,7 +767,7 @@ impl<'a> GlyphIterator<'a> {
fn next_complex_glyph(&mut self, entry: &GlyphEntry, i: CharIndex) fn next_complex_glyph(&mut self, entry: &GlyphEntry, i: CharIndex)
-> Option<(CharIndex, GlyphInfo<'a>)> { -> Option<(CharIndex, GlyphInfo<'a>)> {
let glyphs = self.store.detail_store.get_detailed_glyphs_for_entry(i, entry.glyph_count()); let glyphs = self.store.detail_store.get_detailed_glyphs_for_entry(i, entry.glyph_count());
self.glyph_range = Some(range::each_index(CharIndex(0), CharIndex(glyphs.len() as int))); self.glyph_range = Some(range::each_index(CharIndex(0), CharIndex(glyphs.len() as isize)));
self.next() self.next()
} }
} }

View file

@ -138,7 +138,7 @@ impl TextRunScanner {
}; };
let mut new_line_pos = Vec::new(); let mut new_line_pos = Vec::new();
let old_length = CharIndex(run_text.chars().count() as int); let old_length = CharIndex(run_text.chars().count() as isize);
last_whitespace = util::transform_text(in_fragment.as_slice(), last_whitespace = util::transform_text(in_fragment.as_slice(),
compression, compression,
last_whitespace, last_whitespace,
@ -146,7 +146,7 @@ impl TextRunScanner {
&mut new_line_pos); &mut new_line_pos);
new_line_positions.push(NewLinePositions(new_line_pos)); new_line_positions.push(NewLinePositions(new_line_pos));
let added_chars = CharIndex(run_text.chars().count() as int) - old_length; let added_chars = CharIndex(run_text.chars().count() as isize) - old_length;
new_ranges.push(Range::new(char_total, added_chars)); new_ranges.push(Range::new(char_total, added_chars));
char_total = char_total + added_chars; char_total = char_total + added_chars;
} }