ustring icon indicating copy to clipboard operation
ustring copied to clipboard

remove $offset from indexOf() and lastIndexOf()

Open Wes0617 opened this issue 9 years ago • 2 comments

they are redundant with substring(). there are better ways to avoid unnecessary copies [stringbuilder is one, or interning], provided that we care of this kind of optimizations

Wes0617 avatar Nov 10 '15 06:11 Wes0617

Redundant maybe, but is that a good enough reason to drop it? Being able to specify an offset when finding an index is a common feature of string libraries.

hikari-no-yume avatar Nov 10 '15 10:11 hikari-no-yume

In fact, I'd go so far as to say it's essential. It's not a deduplication trick, it's a means to specify where you are searching in a string. You need this when, for example, searching for multiple occurences of a string within a string. You could truncate the string each time, but this wastes memory and CPU time, and requires you to do arithmetic to find the position in the original string.

hikari-no-yume avatar Mar 17 '16 20:03 hikari-no-yume