-
Notifications
You must be signed in to change notification settings - Fork 91
Open
Labels
Description
Now we had to call Charset
and TabSize
to correctly handle arbitrarily data.
Which at the end of the day does 2 allocations....and whole string pass through 2 times.
Which is quite bad...
We shall move Tabsize
logic into Charset
and make the foremost use Builder
pattern.
So we will set what changes we need to do them all at once.
Specifically a tabsize setting (currently I have 1 in mind) but likely we can came up with more convenient things.
tabled/tabled/src/settings/formatting/tab_size.rs
Lines 46 to 62 in 91fdedb
impl<R, D, C> TableOption<R, C, D> for TabSize | |
where | |
R: Records + ExactRecords + RecordsMut<String> + PeekableRecords, | |
{ | |
fn change(self, records: &mut R, _: &mut C, _: &mut D) { | |
let tab_size = self.0; | |
for row in 0..records.count_rows() { | |
for col in 0..records.count_columns() { | |
let pos = pos(row, col); | |
let text = records.get_text(pos); | |
let text = text.replace('\t', &" ".repeat(tab_size)); | |
records.set(pos, text); | |
} | |
} | |
} | |
} |
text.replace(|c| c != '\n' && c < ' ', "") |