diff options
author | Blaž Hrastnik | 2022-01-17 07:28:56 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-03-17 00:29:47 +0000 |
commit | 59f05088b9628086b35631338e49ae8f061dcba2 (patch) | |
tree | b8e87e318e2194a9473aca0ce799a4e32bffa33a /helix-core/src/graphemes.rs | |
parent | c6bd105484fbaf35812dddc41b8fb32cb054fc54 (diff) |
Optimize rendering by using Ropey::byte_slice
This avoids costly conversions via byte_to_char (which are then
reversed back into bytes internally in Ropey).
Reduces time spent in slice/byte_to_char from ~24% to ~5%.
Diffstat (limited to 'helix-core/src/graphemes.rs')
-rw-r--r-- | helix-core/src/graphemes.rs | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/helix-core/src/graphemes.rs b/helix-core/src/graphemes.rs index aa898684..c0c61775 100644 --- a/helix-core/src/graphemes.rs +++ b/helix-core/src/graphemes.rs @@ -333,10 +333,7 @@ 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)) + Some(self.text.byte_slice(a..b)) } else { let a2 = a - self.cur_chunk_start; let b2 = b - self.cur_chunk_start; |