FNA-XNA / FNA

FNA - Accuracy-focused XNA4 reimplementation for open platforms
https://fna-xna.github.io/
2.65k stars 272 forks source link

Use weak GCHandles instead of WeakReference instances for GraphicsResource #452

Closed kg closed 1 year ago

kg commented 1 year ago

WeakReference is an extra heap allocation per resource that basically exists to give us a finalizer - but we already have one, so we can just use GCHandle directly.

Since the default List.Remove would box the handles to compare them I had to do the Remove manually, but that allows doing an unordered remove anyway for a slight speed boost (that doesn't matter because nobody disposes resources that often)