DavidArno / SuccincT

Discriminated unions, pattern matching and partial applications for C#
MIT License
266 stars 15 forks source link

Option<T>.None optimization #26

Closed megafinz closed 7 years ago

megafinz commented 7 years ago

Added caching to Option<T>.None to avoid unnecessary creation of objects to relieve pressure on GC.

Each Option is a Union<T, None> and each Union<T, None> is a pair of Dictionaries and a couple of Lambdas. Since there is no real need (I hope) to keep different instances of Option<T>.None, I decided to cache them. That helps in case your code "creates" a lot of Option<T>.None objects.