Shadowth117 / PSO2-Aqua-Library

A library for handling PSO2 Aqua formats, with a focus on models. Now functional in grabbing model data from the game's format. Aqua Model Tool provides a basic GUI for doing minor changes to certain model structs.
GNU General Public License v3.0
41 stars 14 forks source link

Optimize UTF-16 string read #14

Closed dummycount closed 3 months ago

dummycount commented 3 months ago

Optimized ReadUTF16String() using code based on the example at https://learn.microsoft.com/en-us/dotnet/api/system.text.decoder.convert?view=net-8.0. This reduces the time to run ReferenceGenerator.ReadCMXText() from 48 seconds to under 1 second on my PC.

A similar change could probably be made to improve the other string read functions, but ReadUTF16String() was the only one I saw getting used a significant amount when reading CMX data, so I didn't change the others.

Shadowth117 commented 3 months ago

This will make it slower than what you had, but we really do need to at least read within the bounds because this game is cruel like that.