CMI: Experimental language.tab optimization
|Reported by:||eriktorbjorn||Owned by:||SF/ender|
|Game:||Monkey Island 3|
This is an experimental patch to speed of the language.tab handling for CMI. Instead of keeping the whole language.tab file in memory and do a linear search every time a text has to be translated, I build an index (a sorted array) of it and use binary search to look up the offset.
At first I had planned to use a balanced tree, but I abandoned that idea when I realized it would easily double the size of the index. Since it's already 118 KB I don't want to do that. Besides, qsort() and bsearch() are almost certainly both less error-prone and better optimized than anything I could come up with.
I guess it shouldn't be too hard to extend this mechanism to also cover The Dig, but I don't have any way to test that.
The difference is particularly noticeable when the game is displaying a conversation menu. The CPU usage still rises alarmingly, leading me to believe that there are further optimizations to do there.
Ticket imported from: #682981. Ticket imported from: patches/276.