36 | 36 | There were several ideas what to optimize currently in the text. The first thing was that clicking around causes too much processing - this was because {{{TextModelLogic}}} was registered twice, {{{SceneInteractionLogic}}} fired the event twice for a frame, and finally because we processed both on {{{MOUSE_PRESSED}}} and on {{{MOUSE_CLICKED}}} with click count 1 ( a total of 2^3^ = 8 times processing the text per click ). Next {{{TextLinkProcessor}}} needed optimizations (it used to process the whole text when called), now it hopefully processes only the changes, but when collaborating with the server and updating according to a list of changes we need to process the text after each change (hopefully the processing will be fast); also optimized applying the style a bit. Finally, {{{ImmHotText.replace}}} used to make some calls to {{{getRunEnd}}} (I don't really understand why, but anyway), which traversed through the whole text if all of it was the same style. I also tried to optimize the calls to {{{getStyledHash}}} (it's calculated linearly since we use a new text when typing/clicking around), but it didn't seem to produce a noticeable performance gain, while we're not able to update the hash correctly in constant time (we can update it a bit incorrectly and hope for no collisions on different texts (which is most likely for meaningful texts), but as I said, I didn't notice a gain) |