Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lujian101/GCFreeClosure
A gc-free closure implementation for unity
https://github.com/lujian101/GCFreeClosure
Last synced: 4 months ago
JSON representation
A gc-free closure implementation for unity
- Host: GitHub
- URL: https://github.com/lujian101/GCFreeClosure
- Owner: lujian101
- Created: 2017-08-14T07:43:56.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-28T11:51:48.000Z (about 6 years ago)
- Last Synced: 2024-01-14T19:10:45.954Z (5 months ago)
- Language: C#
- Size: 14.6 KB
- Stars: 81
- Watchers: 7
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Lists
- awesome-unity3d - GCFreeClosure - About (Open Source Repositories / Utilities)
README
# GCFreeClosure
A gc-free closure implementation for unity
GC-Alloc has always been a kind of important performance measurement standard, so we should keep gc-alloc as less as possible.
GCFreeClosure is designed for avoiding gc memory allocation.
example:
```C#
//-----------------------------------------------------------------------------------
var action = ActionClosure.Create( ( a, b ) => UDebug.Print( a + b ), 1, 2 );
action.Invoke();var function = FuncClosure.Create( ( a, b ) => a + b, 1, 2 );
var c = function.Invoke();// use Tuple to pack multi-value together
var function2 = FuncClosure.Create( ctx => ctx.Item1 + ctx.Item2, STuple.Create( 1, 2 ) );
// call with return value
var c2 = function2.Invoke();//-----------------------------------------------------------------------------------
var id = 1;
// system library implementation will cause gc-alloc for each function call.
list.FindIndex( e => e == id );// replace system implementation to avoid gc-alloc
list.FindIndex( ( _id, e ) => e == _id, id );
```