IllusionMods / IllusionFixes

A collection of fixes for common issues found in games by Illusion
GNU General Public License v3.0
157 stars 29 forks source link

Improved IsFileValid being very slow in huge scenes #54

Closed takahiro0327 closed 6 months ago

takahiro0327 commented 6 months ago

Fixed the function IsFileValid, which was very slow on huge scenes (200MB). Please merge.

A simple measurement of the execution time with the following code showed that the time was reduced from 150s to 1s.

        private static bool OnClickLoadPrefix(List<string> ___listPath, int ___select)
        {
            var path = ___listPath[___select];
            System.DateTime begin = System.DateTime.Now;
            bool ok = IsFileValid(path);
            System.DateTime end = System.DateTime.Now;
            Logger.LogDebug($"@@@ {(end - begin).TotalSeconds}");
            return ok;
        }

This incident was a lesson to me that it is not good to copy easily from stackoverflow. By the way, KMPSearch copied from ChatGPT after a little testing.