Skip to content

Commit

Permalink
reuse StringBuilder instances
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenberger committed Sep 15, 2014
1 parent c42337d commit 207f3c6
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ private PathToken analyzeCriteriaSequence() {
}
criteria.add(createCriteria(pathBuffer, operatorBuffer, valueBuffer));

pathBuffer = new StringBuilder();
operatorBuffer = new StringBuilder();
valueBuffer = new StringBuilder();
pathBuffer.setLength(0);
operatorBuffer.setLength(0);
valueBuffer.setLength(0);

} else if (operatorBuffer.length() > 0) {
valueBuffer.append(current);
Expand Down Expand Up @@ -369,7 +369,7 @@ private PathToken analyzeProperty() {
case '\'':
if (propertyIsOpen) {
properties.add(buffer.toString());
buffer = new StringBuilder();
buffer.setLength(0);
propertyIsOpen = false;
} else {
propertyIsOpen = true;
Expand Down Expand Up @@ -417,7 +417,7 @@ private PathToken analyzeArraySequence() {
current = chars[++i];
}
String function = buffer.toString();
buffer = new StringBuilder();
buffer.setLength(0);
if (!function.equals("size") && !function.equals("length")) {
throw new InvalidPathException("Invalid function: @." + function + ". Supported functions are: [(@.length - n)] and [(@.size() - n)]");
}
Expand Down Expand Up @@ -450,11 +450,11 @@ private PathToken analyzeArraySequence() {
current = chars[++i];
}
numbers.add(Integer.parseInt(buffer.toString()));
buffer = new StringBuilder();
buffer.setLength(0);
} else {
//we now this starts with [12:???
numbers.add(Integer.parseInt(buffer.toString()));
buffer = new StringBuilder();
buffer.setLength(0);
current = chars[++i];

//this is a tail slice [:12]
Expand All @@ -470,13 +470,13 @@ private PathToken analyzeArraySequence() {
} else {
sliceBetween = true;
numbers.add(Integer.parseInt(buffer.toString()));
buffer = new StringBuilder();
buffer.setLength(0);
}
}
break;
case ',':
numbers.add(Integer.parseInt(buffer.toString()));
buffer = new StringBuilder();
buffer.setLength(0);
indexSequence = true;
break;
default:
Expand Down

0 comments on commit 207f3c6

Please sign in to comment.