Re:TIL the assumption that string length does not change whe...
by s_gourichon on Monday November 22, 2021 @01:22AM
(#29303421)
Since you ask for an example: moving the cursor in a terminal-based text editor requires #2 string length. That said I understand your point about focusing on what is actually needed.
[ Parent
| on HN ]
Re:TIL the assumption that string length does not change whe...
by yorwba on Monday November 22, 2021 @04:55AM
(#29304678)
Moving the cursor doesn't require string length, it requires finding the new cursor position. You can compute #2 length by moving the cursor one grapheme cluster at a time until you hit the end, but if you only need to move the cursor once, the length is irrelevant. (Also, cursor positions in a terminal-based text editor don't necessarily correspond to graphemes.)