Speed optimization

This commit is contained in:
daa84 2017-09-14 18:34:08 +03:00
parent 211ef0de58
commit faeac76607
2 changed files with 5 additions and 16 deletions

View File

@ -38,9 +38,7 @@ pub fn render(
let mut line_x = 0.0; let mut line_x = 0.0;
let RowView { line, row, line_y, .. } = cell_view; let RowView { line, row, line_y, .. } = cell_view;
for col in 0..line.line.len() { for (col, cell) in line.line.iter().enumerate() {
let cell = &line.line[col];
draw_cell(&cell_view, color_model, cell, col, line_x); draw_cell(&cell_view, color_model, cell, col, line_x);
@ -172,9 +170,9 @@ pub fn shape_dirty(
let items = ctx.itemize(&styled_line); let items = ctx.itemize(&styled_line);
line.merge(&styled_line, &items); line.merge(&styled_line, &items);
for i in 0..line.line.len() { for (col, cell) in line.line.iter_mut().enumerate() {
if line[i].dirty { if cell.dirty {
if let Some(item) = line.get_item_mut(i) { if let Some(item) = line.item_line[col].as_mut() {
let mut glyphs = pango::GlyphString::new(); let mut glyphs = pango::GlyphString::new();
{ {
let analysis = item.analysis(); let analysis = item.analysis();
@ -192,7 +190,7 @@ pub fn shape_dirty(
} }
} }
line[i].dirty = false; cell.dirty = false;
} }
line.dirty_line = false; line.dirty_line = false;

View File

@ -158,15 +158,6 @@ impl Line {
self.item_line[start_cell] = Some(Item::new(new_item.clone(), end_cell - start_cell + 1)); self.item_line[start_cell] = Some(Item::new(new_item.clone(), end_cell - start_cell + 1));
} }
pub fn get_item_mut(&mut self, cell_idx: usize) -> Option<&mut Item> {
let item_idx = self.cell_to_item(cell_idx);
if item_idx >= 0 {
self.item_line[item_idx as usize].as_mut()
} else {
None
}
}
pub fn get_item(&self, cell_idx: usize) -> Option<&Item> { pub fn get_item(&self, cell_idx: usize) -> Option<&Item> {
let item_idx = self.cell_to_item(cell_idx); let item_idx = self.cell_to_item(cell_idx);
if item_idx >= 0 { if item_idx >= 0 {