Speed optimization

This commit is contained in:
daa 2018-05-05 23:08:40 +03:00
parent bda35efe88
commit df04e7d44a
1 changed files with 5 additions and 2 deletions

View File

@ -243,8 +243,11 @@ pub struct StyledLine {
impl StyledLine {
pub fn from(line: &Line, color_model: &color::ColorModel) -> Self {
let mut line_str = String::new();
let mut cell_to_byte = Vec::new();
let average_capacity = line.line.len() * 4 * 2; // code bytes * grapheme cluster
let mut line_str = String::with_capacity(average_capacity);
let mut cell_to_byte = Vec::with_capacity(average_capacity);
let attr_list = pango::AttrList::new();
let mut byte_offset = 0;
let mut style_attr = StyleAttr::new();