Skip to content

optimize - #23

Open
HEIHUAa wants to merge 4 commits into
CodenameCrew:codename-devfrom
HEIHUAa:optimize
Open

optimize#23
HEIHUAa wants to merge 4 commits into
CodenameCrew:codename-devfrom
HEIHUAa:optimize

Conversation

@HEIHUAa

@HEIHUAa HEIHUAa commented Sep 10, 2026

Copy link
Copy Markdown

Since the last code optimization, I've been making changes here and there, and now it's time to summarize them.

Optimized operations like x += 1: previously they would allocate a closure (creating a temporary function) and x would require two variable lookups. Now it's directly cached, no closure allocation is needed, and it's about 35% faster.

Previously, in for (i in 0...10), a variable object was recreated after each loop iteration. Now it's reused.

Optimized reading engine object fields: previously it had to check twice whether it was a special script object each time. Now the result is cached directly, improving speed by about 16%.

Optimized creating many instances of the same object with new: specifically, instead of doing a table lookup every time, the result is now cached. Creating the same object 10,000 times is about 20% faster.

Improved the speed of reading fields that are originally null, such as FlxG.save.data.xxx, by about 15% (only for hscriptPos).

Previously, function parameter declarations + loop variables + locals would all create a new internal record object. Now they are reused.

Merged the two sets of code for assign/evalAssignOp to remove duplication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant