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

Improve type nullability for IntervalSet #174

Merged
merged 4 commits into from
Feb 16, 2024

Conversation

lppedd
Copy link
Contributor

@lppedd lppedd commented Feb 15, 2024

IntervalSet seems to be a hot path, so the less nullability checks we have, and the less iterators we use, the better.

Also tested with the ANTLR 5 test suite.

Copy link
Member

@ftomassetti ftomassetti left a comment

Choose a reason for hiding this comment

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

Good, but I added a few comments about minor changes

@@ -143,7 +143,7 @@ public class IntervalSet : IntSet {
}
}

private var _intervals: MutableList<Interval> = ArrayList(8)
private var _intervals: MutableList<Interval> = ArrayList(16)
Copy link
Member

Choose a reason for hiding this comment

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

Should we use a constant or provide an explanation for the "magic constant"?

@Suppress("LocalVariableName")
val I = iter.next()
while (i < n) {
val I = _intervals[i++]
Copy link
Member

Choose a reason for hiding this comment

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

having i and capital I is a bit confusing. I would call this one currInterval and i -> index

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I know, names are not the best! But I'd like to keep it as it is to match ANTLR 4.

@Suppress("LocalVariableName")
val I = iter.next()
while (i < n) {
val I = _intervals[i++]
Copy link
Member

Choose a reason for hiding this comment

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

Same renaming here

@ftomassetti
Copy link
Member

Thank you @lppedd !

@ftomassetti ftomassetti merged commit 8b89e36 into Strumenta:master Feb 16, 2024
6 checks passed
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.

None yet

2 participants