diff options
author | Matt Brubeck <mbrubeck@limpet.net> | 2016-04-01 15:58:00 -0700 |
---|---|---|
committer | Matt Brubeck <mbrubeck@limpet.net> | 2016-04-07 16:00:14 -0700 |
commit | bcaa62e1bd1c5b516370d85ae194f8a1bbd61726 (patch) | |
tree | 202956331d219981ac1ec5ce2e1a5c589e9925bb /components/layout/text.rs | |
parent | 39ab006c8f71404d2fcd81f7715b7b9e47d5aead (diff) | |
download | servo-bcaa62e1bd1c5b516370d85ae194f8a1bbd61726.tar.gz servo-bcaa62e1bd1c5b516370d85ae194f8a1bbd61726.zip |
Slight refactoring of RunMapping flush method
Diffstat (limited to 'components/layout/text.rs')
-rw-r--r-- | components/layout/text.rs | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/components/layout/text.rs b/components/layout/text.rs index 0fb9e7cde05..7c311e05af1 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -230,17 +230,15 @@ impl TextRunScanner { let flush_mapping = flush_run || mapping.selected != selected; if flush_mapping { - if end_position > start_position { - mapping.flush(&mut mappings, - &mut run_info, - &**text, - insertion_point, - compression, - text_transform, - &mut last_whitespace, - &mut start_position, - end_position); - } + mapping.flush(&mut mappings, + &mut run_info, + &**text, + insertion_point, + compression, + text_transform, + &mut last_whitespace, + &mut start_position, + end_position); if run_info.text.len() > 0 { if flush_run { run_info_list.push(run_info); @@ -261,11 +259,6 @@ impl TextRunScanner { *paragraph_bytes_processed += character.len_utf8(); } - // If the mapping is zero-length, don't flush it. - if start_position == end_position { - continue - } - // Flush the last mapping we created for this fragment to the list. mapping.flush(&mut mappings, &mut run_info, @@ -557,6 +550,9 @@ impl RunMapping { last_whitespace: &mut bool, start_position: &mut usize, end_position: usize) { + if *start_position == end_position { + return; + } let old_byte_length = run_info.text.len(); *last_whitespace = util::transform_text(&text[(*start_position)..end_position], compression, |