trunk8
trunk8 copied to clipboard
Option to snip at word boundary
Would be a useful feature. Thanks.
+1 truncate by word boundary would be great!
Wondering about the performance hits this may incur.
The current method to find the best truncation is a modified binary search. So at worst, the search takes O(lg(n)).
The way I'm thinking to implement this would be to binary search as usual, but scan the string left or right (depending on the side
setting) until the cut is made on a word boundary. This would be O(n) because you scan after finding the optimal cut.
Can this be faster?
Maybe you could let word boundary as optional, and keep the current search method when word boundary is disabled. That way, the performance would remain unaffected on the default case.
Yeah, I agree it'd be better to make this opt-in.
Curious if it can be made just as fast as the default functionality.
Hi, are you planning to implement this enhancement? Thanks!
@afarriaga This is high on my list for trunk8 but I don't have the time. Pull requests are welcome!
+1 for this option.
+1 for this option and a 'trunkOnWord' ;)