Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/snozbot/FastString
- Owner: snozbot
- License: mit
- Created: 2017-05-03T14:04:10.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-03T14:39:30.000Z (over 7 years ago)
- Last Synced: 2024-07-14T14:33:42.324Z (4 months ago)
- Language: C#
- Homepage:
- Size: 31.3 KB
- Stars: 88
- Watchers: 8
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-unity-open-source-on-github - FastString - Alternative to StringBuilder class for Unity games (Optimization)
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.