Skip to content

Commit

Permalink
termwiz: TeenyString: use heap string when col width > 2
Browse files Browse the repository at this point in the history
This isn't currently possible, but
#4223 will introduce that
possibility.  This commit causes width > 2 to "overflow" into
the heap-stored variant.

Sequences that are long enough to produce a column width > 2 are
likely to already be long enough in bytes to overlow into the
heap-stored variant anyway.
  • Loading branch information
wez committed Sep 28, 2023
1 parent 0f894d7 commit 6198e3d
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions termwiz/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,7 @@ impl TeenyString {
let len = bytes.len();
let width = width.unwrap_or_else(|| grapheme_column_width(s, unicode_version));

if len < std::mem::size_of::<u64>() {
debug_assert!(width < 3);

if len < std::mem::size_of::<u64>() && width < 3 {
let mut word = 0u64;
unsafe {
std::ptr::copy_nonoverlapping(
Expand Down

0 comments on commit 6198e3d

Please sign in to comment.