-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Replace StringBuffer with StringBuilder where possible #30964
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,7 @@ public Object getValue(String key) throws IOException { | |
* String*Buffer* because that is what the Matcher API takes. In modern versions of java the uncontended synchronization is very, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment looks obsolete There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I should read more comments to save me some trouble ;-) Nik is right here of course. |
||
* very cheap so that should not be a problem. | ||
*/ | ||
StringBuffer result = new StringBuffer(key.length()); | ||
StringBuilder result = new StringBuilder(key.length()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one also has the same problem with java 8. |
||
if (false == matcher.find()) { | ||
throw new IllegalArgumentException("Doesn't contain any stash keys [" + key + "]"); | ||
} | ||
|
@@ -191,7 +191,7 @@ private Object getValue(List<Object> path, String key) throws IOException { | |
} | ||
} | ||
String builtPath = Matcher.quoteReplacement(pathBuilder.toString()); | ||
StringBuffer newKey = new StringBuffer(key.length()); | ||
StringBuilder newKey = new StringBuilder(key.length()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one also uses a Java 9 method. |
||
do { | ||
matcher.appendReplacement(newKey, builtPath); | ||
} while (matcher.find()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ static String convertToString( byte[] bytes ) | |
} | ||
|
||
char[] hex = Hex.encodeHex( bytes ); | ||
StringBuffer sb = new StringBuffer(); | ||
StringBuilder sb = new StringBuilder(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that we should avoid changing this source file. It is from upstream (see #30972 to fix the license) and we should not deviate unless absolutely necessary (it could get reverted in a future import from upstream anyway). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, will close this then. |
||
|
||
// start with 'S' | ||
sb.append( 'S' ); | ||
|
@@ -65,7 +65,7 @@ static String convertToString( byte[] bytes ) | |
// sub-authorities, little-endian | ||
for ( int i = 0; i < count; i++ ) | ||
{ | ||
StringBuffer rid = new StringBuffer(); | ||
StringBuilder rid = new StringBuilder(); | ||
|
||
for ( int k = 3; k >= 0; k-- ) | ||
{ | ||
|
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.
This one has the same problem with java 8.