Skip to content

Make logical operators short-circuit where possible - #750

Open
triallax wants to merge 1 commit into
sharkdp:mainfrom
triallax:short-circuiting
Open

Make logical operators short-circuit where possible#750
triallax wants to merge 1 commit into
sharkdp:mainfrom
triallax:short-circuiting

Conversation

@triallax

@triallax triallax commented Jul 6, 2025

Copy link
Copy Markdown
Contributor

More efficient but also in line with most other languages out there.

More efficient but also in line with most other languages out there.

@Goju-Ryu Goju-Ryu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution, I’m excited to see short-circuiting being added to numbat.

I don't have a good enough understanding of this part of the project to give much feedback, but it looks really promising. I had two comments, mostly just to clarify some points.

Comment thread numbat/src/bytecode_interpreter.rs

let else_block_offset = self.vm.current_offset();
self.vm
.patch_u16_value_at(jump_offset, else_block_offset - (jump_offset + 2));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit unclear to me. I think I follow, but a comment to explain what is happening would be helpful.

@triallax

triallax commented Jul 7, 2025

Copy link
Copy Markdown
Contributor Author

now i also realise documenting this behaviour, even if briefly is probably useful, so i'll add that in as well

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.

2 participants