vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
454 stars 72 forks source link

Optimized file generation in WavefrontWriter. #167

Closed MeltyPlayer closed 1 year ago

MeltyPlayer commented 1 year ago

Switches the WavefrontWriter from generating bytes for each file upfront and then saving them to generating bytes lazily via delegates.

Specifically, the old process involved writing to a StringBuilder, saving that to a MemoryStream, and then saving those bytes through File.WriteAllBytes(); now, the new process just writes directly to the FileStream via the Stream interface.

This results in less memory being allocated in total, and allocations being freed up sooner so that they can be reclaimed by the garbage collector.