Skip to content

StringBuilder that uses an internal LongArray #790

@gavinking

Description

@gavinking

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions