A memory-saving type for Collections of Strings

I made a pull request for a new Collection type. Like many containers with variable element counts, String stores its character data in a dynamic memory block. Since the standard collections do the same thing, a collection of strings ends up with several allocated blocks. The way around that is a specialized collection that mushes all the allocations together. That's what StringCollection does.

String doesn't always heap allocate. For example for immortal static strings that are known at compile time, or for Strings of 15 or less utf8 bytes (usually).

What is your usecase for this type? Given the inherent restrictions it comes with.

How is this type different from just using a String as the collection, and Substrings of that String as the subsequnces?

It would be nice to know concrete usecases and issues solved by this type, and optimally we'd have benchmarks (more optimally, benchmarks we can run / reproduce too), that are not too specific to certain usecases (the type needs to perform adequately at all/most times).

2 Likes