Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/snozbot/FastString

Alternative to StringBuilder class for Unity games, with minimal memory allocation and faster performance.
https://github.com/snozbot/FastString

Last synced: 3 months ago
JSON representation

Alternative to StringBuilder class for Unity games, with minimal memory allocation and faster performance.

Awesome Lists containing this project

README

        

# FastString
Alternative to the [StringBuilder class](https://msdn.microsoft.com/en-us/library/system.text.stringbuilder(v=vs.110).aspx) for Unity games, with minimal memory allocation and faster performance.
Based on [FastString](https://www.reddit.com/r/Unity3D/comments/3zz62z/alternative_to_stringbuilder_without_memory/) by Nicolas Gadenne of [Gaddy Games](http://gaddygames.com/site/)

The class has been designed to be most useful in common game situations: a concatenation of a few string and data, then used by a Unity api method as an immutable string - every frame.
It handles Append() and Replace() without doing any allocation, except for very rare capacity augmentation (contrary to StringBuilder which surprisingly does capacity change very often).
It also appends float and int numbers without any allocation.

The only common memory allocation is when you retrieve the final immutable string - but this is only done when required.

# Running the tests

A Unity project is provided for testing the performance.

- To run the performance tests, open the FastStringTest scene and the Profiler ( Window > Profiler ).
- Run the scene in the editor and then stop it again.
- Enter 'Test' in the profile search to see the profile results for each technique.