-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Optimize ATN serialization data #3513
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
Conversation
I don't exactly why CI reports not found |
@parrt please take a look at this optimization, it does not break anything. |
looks like there's some very good stuff in here. My brain is stuck on the other thing at the moment so let me finish up there. |
Sorry. Let's resolve #3515 quickly before we resolve this PR. |
Copying comment over here... "Actually, concerning this PR, why not use the binary string in the parser file like others? Now Swift build is much more complicated, isn't it?" |
b0228ac
to
1c464ae
Compare
case "Java": | ||
case "JavaScript": | ||
case "Python2": | ||
case "Python3": | ||
return String.format("\\u%04x", v); | ||
case "CSharp": | ||
return String.format("\\x%X", v); | ||
case "Dart": | ||
case "PHP": | ||
case "Swift": | ||
return String.format("\\u{%X}", v); |
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.
I suggest adding StandardTarget
eventually (we were discussing the question some time ago) to get rid of the risk of misprinting in string literal:
class StandardTarget {
public final static String Java = "Java";
...
}
or add constants to each target:
class JavaTarget {
public final static String Key = "Java";
}
Those constants are used over the repository in many places.
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.
If the Constants are used a lot, I can see creating such a mechanism. For now, let's focus on just the changes directly in the serialization.
1c464ae
to
bcb4232
Compare
…output files Fix creation of excess fragments for Dart, Cpp, PHP runtimes
bcb4232
to
488f594
Compare
Wow. I love it! You removed a whole bunch of code, and made things much easier to understand. Well done!!! Not only that, the generated code is significantly smaller🕺. Merging... all tests are passing |
Using plain chars for serialized ATN data instead of escaped where it's possible. Fixed the bug with the max size of ATN segment introduced in #3438.
I've compared the size of source files for
largeLexer
test:Also, I've fixed binary serialization in Swift and replaced JSON serialization.
Please do not squash since all commits are atomic.