WizzardMaker / AirlineTycoon

Source code of Airline Tycoon based on the GOG source code release
https://www.gog.com/game/airline_tycoon_deluxe
Other
27 stars 9 forks source link

Feat language specify string #62

Closed mertenpopp closed 1 month ago

mertenpopp commented 1 month ago

I noticed that regular expression parsing for handling multilingual strings causes high CPU load.

First commit caches the regular expression so that it is not compiled every time a string is translated.

Honestly though, the old implementation with just two nested loops is much faster than a regex. I put it back in and made it more readable. This is the second commit.

Pick the solution that you like most.

WizzardMaker commented 1 month ago

Well, I should've known that more readable code comes at the cost of performance. I've initially rewritten the code to regex due to some experiments in changing the language handling, but I've never really finished anything in that direction, except for the regex rewrite for the handling of unknown language strings.

I like your second approach, a lot more readable than the original. Although I like the readability of the regex implementation more, I think because this code somewhat lies on the hot path we should go with your current reimplementation proposal.

Are you done with this PR, so that I can merge it?

mertenpopp commented 1 month ago

Yes, I am done and you can merge it!