Did some basic optimizations that made things fast again. Yay!
The basis for the optimizations were some less basic changes made in Ropey.
This commit is contained in:
parent
5ca0f5e406
commit
b19997b975
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -8,7 +8,7 @@ dependencies = [
|
|||
"serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -88,7 +88,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
[[package]]
|
||||
name = "ropey"
|
||||
version = "0.6.3"
|
||||
source = "git+https://github.com/cessen/ropey#e9b361b5b45d3e389bbfcb4f75127bec69e0b199"
|
||||
source = "git+https://github.com/cessen/ropey#140e79caa4b8d0215e6f0b70c7269a6715e53498"
|
||||
dependencies = [
|
||||
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -166,7 +166,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.2.0"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -218,7 +218,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
|
||||
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
|
||||
"checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963"
|
||||
"checksum unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8083c594e02b8ae1654ae26f0ade5158b119bd88ad0e8227a5d8fcd72407946"
|
||||
"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1"
|
||||
"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
|
||||
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
|
||||
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
|
||||
|
|
|
@ -15,7 +15,7 @@ use utils::{digit_count, RopeGraphemes};
|
|||
|
||||
pub mod formatter;
|
||||
mod screen;
|
||||
mod smallstring;
|
||||
pub mod smallstring;
|
||||
|
||||
use self::screen::{Color, Screen, Style};
|
||||
|
||||
|
|
11
src/utils.rs
11
src/utils.rs
|
@ -16,9 +16,8 @@ pub fn digit_count(mut n: u32, b: u32) -> u32 {
|
|||
//=============================================================
|
||||
|
||||
pub fn grapheme_width(slice: &RopeSlice) -> usize {
|
||||
// TODO: use a small stack-allocated buffer to handle the common case
|
||||
// without allocation.
|
||||
let s = slice.to_string();
|
||||
use term_ui::smallstring::SmallString;
|
||||
let s = SmallString::from_rope_slice(slice);
|
||||
return UnicodeWidthStr::width(&s[..]);
|
||||
}
|
||||
|
||||
|
@ -167,10 +166,16 @@ impl<'a> Iterator for RopeGraphemes<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
if a < self.cur_chunk_start {
|
||||
let a_char = self.text.byte_to_char(a);
|
||||
let b_char = self.text.byte_to_char(b);
|
||||
|
||||
Some(self.text.slice(a_char..b_char))
|
||||
} else {
|
||||
let a2 = a - self.cur_chunk_start;
|
||||
let b2 = b - self.cur_chunk_start;
|
||||
Some(RopeSlice::from_str(&self.cur_chunk[a2..b2]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user