-
Notifications
You must be signed in to change notification settings - Fork 47
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
Conversation
There was a problem hiding this 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) |
There was a problem hiding this comment.
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"?
antlr-kotlin-runtime/src/commonMain/kotlin/org/antlr/v4/kotlinruntime/misc/IntervalSet.kt
Outdated
Show resolved
Hide resolved
@Suppress("LocalVariableName") | ||
val I = iter.next() | ||
while (i < n) { | ||
val I = _intervals[i++] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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++] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same renaming here
9d4fc2a
to
a413287
Compare
Thank you @lppedd ! |
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.