-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Use StringBuilder instead of StringBuffer #1010
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
@@ -89,7 +89,7 @@ private static String initialise(Token currentToken, | |||
int[][] expectedTokenSequences, | |||
String[] tokenImage) { | |||
String eol = System.getProperty("line.separator", "\n"); | |||
StringBuffer expected = new StringBuffer(); | |||
StringBuilder expected = new StringBuilder(); |
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.
You're updating a bunch of autogen code... it will just get undone the next time these tools get updated. I'm pretty averse to separating this out myself
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.
Oh, any hint about those tools, how can one run/change them?
For example, the precompiled code is in
edu/stanford/nlp/trees/tregex/TregexParser.jj
Generated using javacc. We tried to be nice and leave sample command lines:
// javacc
"-OUTPUT_DIRECTORY=projects/core/src/edu/stanford/nlp/trees/tregex"
projects/core/src/edu/stanford/nlp/trees/tregex/TregexParser.jj
guess that sort of gives away our internal paths, but whatever.
Here is an exciting discovery, btw. The last time someone did an automated
sed replace or whatever it is you've done, they missed that they were
updating some autogen files. So, for example, the original TregexParser.jj
still looked for edu.stanford.nlp.util.Function, even though that
functionality (ha, ha) was eventually incorporated into java.
Anyway, javacc supposedly has an option to use StringBuilder instead of
StringBuffer, but turning that option on has no effect on the
ParseException or TokenMgrError classes. I filed an issue on the javacc
github. Let's see what happens
javacc/javacc#165
…On Tue, Mar 3, 2020 at 8:39 AM Ahmed Ashour ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/edu/stanford/nlp/ling/tokensregex/parser/ParseException.java
<#1010 (comment)>:
> @@ -89,7 +89,7 @@ private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
- StringBuffer expected = new StringBuffer();
+ StringBuilder expected = new StringBuilder();
Oh, any hint about those tools, how can one run/change them?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1010?email_source=notifications&email_token=AA2AYWMTMF26MWUWQATP3KLRFUXDVA5CNFSM4LAJ4LX2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCXYV5PQ#discussion_r387147575>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA2AYWMQCGL7SFX24I63AULRFUXDVANCNFSM4LAJ4LXQ>
.
|
We integrated the updated javacc, so if you're up for revisiting this old PR, we'd be able to integrate it now |
I rebased it against dev and merged it here: |
Thanks! |
As you know,
StringBuilder
is the new way, as I don't think the synchronization feature ofStringBuffer
is needed.I declare that the contribution is in the public domain.