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

Misc optimizations that address some of the XXX comments #202

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

linxuanm
Copy link
Contributor

@linxuanm linxuanm commented Oct 2, 2024

This PR resolves some of the XXX todos.

// to Range<T> should be pretty much free.
component RangeUtil {
// Assumes that the vector is sorted.
def binarySearch<T>(range: Range<T>, val: T, lt: (T, T) -> bool) -> int {
Copy link
Owner

Choose a reason for hiding this comment

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

I like this method. I think it should live in Virgil's lib/util and have some unittests.

for (i < entries.length) {
var e = entries[i];
if (e.0 == pc) match (e.1) {
var lower = RangeUtil.lowerbound(entries, (pc, null), cmp_lt_pc);
Copy link
Owner

Choose a reason for hiding this comment

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

If you're looking for an exact match, I think it makes sense to have a utility method that specifically finds an exact match.

src/engine/v3/V3Interpreter.v3 Outdated Show resolved Hide resolved
src/engine/Sidetable.v3 Outdated Show resolved Hide resolved
src/engine/CodeValidator.v3 Outdated Show resolved Hide resolved
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