skadistats / clarity

Comically fast Dota 2, CSGO, CS2 and Deadlock replay parser written in Java.
BSD 3-Clause "New" or "Revised" License
664 stars 122 forks source link

optimize `arrayIdxToString` #290

Closed blukai closed 1 year ago

blukai commented 1 year ago

maximum amount of digits in index is 4, therefore instead of using String.format, which under the hood uses regex to parse provided format and then performs formatting, we get amount of leading zeroes with simple if statements.

in stratz's parser 2.3% of cpu time was spent in skadistats.clarity.io.Util.arrayIdxToString. with this version of arrayIdxToString only arrayIdxToString consumes only 0.21% of cpu time, which is nearly 11 times faster than before.