Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lua] Fix bug in genlua causing significant slowdown in all loops. #11453

Merged
merged 1 commit into from
Dec 28, 2023
Merged

[lua] Fix bug in genlua causing significant slowdown in all loops. #11453

merged 1 commit into from
Dec 28, 2023

Conversation

Zorbn
Copy link
Contributor

@Zorbn Zorbn commented Dec 28, 2023

The condition on line 585 was missing a begin/end block so the generator was unconditionally modifying a variable named _hx_do_first_* which was supposed to only exist for do-while loops.

Since the code that initializes _hx_do_first_* doesn't have this problem, no local variable is created, which means that this bug causes a global variable access for every iteration of every non do-while loop (very bad for performance). Fixing this improved the performance of loops by about 30% in my limited testing. They are now the same speed as writing a loop in Lua by hand.

@Simn
Copy link
Member

Simn commented Dec 28, 2023

Nice catch, thanks!

@Simn Simn merged commit d847c9c into HaxeFoundation:development Dec 28, 2023
61 checks passed
@skial skial mentioned this pull request Dec 30, 2023
1 task
0b1kn00b pushed a commit to 0b1kn00b/haxe that referenced this pull request Jan 25, 2024
@jdonaldson
Copy link
Member

Good catch, regards.

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.

3 participants