mirror of https://github.com/apache/jclouds.git
Avoid unnecessary object creation
Prefer StringBuffer.append(string, index1, index2) over StringBuffer.append(String.substring(index1, index2).
This commit is contained in:
parent
309c053c77
commit
5b5e713cba
|
@ -174,7 +174,7 @@ public class Sha512Crypt {
|
|||
|
||||
while (saltBuf.length() < 16) {
|
||||
int index = (int) (randgen.nextFloat() * SALTCHARS.length());
|
||||
saltBuf.append(SALTCHARS.substring(index, index + 1));
|
||||
saltBuf.append(SALTCHARS, index, index + 1);
|
||||
}
|
||||
|
||||
shadowPrefix = saltBuf.toString();
|
||||
|
|
|
@ -160,14 +160,14 @@ public class Strings2 {
|
|||
int i = 0;
|
||||
while (matcher.find()) {
|
||||
String replacement = replacements.get(matcher.group(1));
|
||||
builder.append(input.substring(i, matcher.start()));
|
||||
builder.append(input, i, matcher.start());
|
||||
if (replacement == null)
|
||||
builder.append(matcher.group(0));
|
||||
else
|
||||
builder.append(replacement);
|
||||
i = matcher.end();
|
||||
}
|
||||
builder.append(input.substring(i, input.length()));
|
||||
builder.append(input, i, input.length());
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -369,7 +369,8 @@ public class ChefSolo implements Statement {
|
|||
if (jsonAttributes.isPresent()) {
|
||||
// Start the node configuration with the attributes, but remove the
|
||||
// last bracket to append the run list to the json configuration
|
||||
json.append(jsonAttributes.get().substring(0, jsonAttributes.get().lastIndexOf('}')));
|
||||
String attributes = jsonAttributes.get();
|
||||
json.append(attributes, 0, attributes.lastIndexOf('}'));
|
||||
json.append(",");
|
||||
} else {
|
||||
json.append("{");
|
||||
|
|
|
@ -86,14 +86,14 @@ public class Utils {
|
|||
int i = 0;
|
||||
while (matcher.find()) {
|
||||
String replacement = replacements.get(matcher.group(1));
|
||||
builder.append(input.substring(i, matcher.start()));
|
||||
builder.append(input, i, matcher.start());
|
||||
if (replacement == null)
|
||||
builder.append(matcher.group(0));
|
||||
else
|
||||
builder.append(replacement);
|
||||
i = matcher.end();
|
||||
}
|
||||
builder.append(input.substring(i, input.length()));
|
||||
builder.append(input, i, input.length());
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue