-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
As per this comment on reddit, there is a usage pattern for StringBuilder that we've never really considered, and that seems to be extremely difficult to optimize given the current implementation.
But if StringBuilder were to store its characters in a Java LongArray, we could optimize the for loop to use by-index access.
The question is whether we could then make StringBuilder.string efficient enough. I think it's likely that we could, with some finesse. If not, then perhaps we just need a separate class (StringBuffer??) that behaves like this. The idea being that it's not meant for "building strings", but for aggregating and reading Characters.
Those really are two separate usage patterns, actually.