2 ms·
That requires storing an extra two fields per String (int length, offset;), which is costly. Users who need constant-time substrings can simply implement their
by mhaymo 11y ago
That requires storing an extra two fields per String (int length, offset;), which is costly. Users who need constant-time substrings can simply implement their own class `Subsequence extends CharSequence` with a constructor taking a CharSequence and two ints. Users who need to pass a substring to a foreign function which only accepts String do need to copy, but that's not a major enough use-case to justify upping the memory usage of most applications.