Another small optimization.
This commit is contained in:
parent
b19997b975
commit
9348a9a916
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -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#140e79caa4b8d0215e6f0b70c7269a6715e53498"
|
||||
source = "git+https://github.com/cessen/ropey#e6a449e07841da690f369eeb9ef05d55fe102623"
|
||||
dependencies = [
|
||||
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
|
@ -17,8 +17,12 @@ pub fn digit_count(mut n: u32, b: u32) -> u32 {
|
|||
|
||||
pub fn grapheme_width(slice: &RopeSlice) -> usize {
|
||||
use term_ui::smallstring::SmallString;
|
||||
let s = SmallString::from_rope_slice(slice);
|
||||
return UnicodeWidthStr::width(&s[..]);
|
||||
if let Some(text) = slice.as_str() {
|
||||
return UnicodeWidthStr::width(text);
|
||||
} else {
|
||||
let text = SmallString::from_rope_slice(slice);
|
||||
return UnicodeWidthStr::width(&text[..]);
|
||||
}
|
||||
}
|
||||
|
||||
/// Finds the previous grapheme boundary before the given char position.
|
||||
|
|
Loading…
Reference in New Issue
Block a user