Optimized trimTrailingSpaces

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1300780 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Bourg 2012-03-14 23:12:57 +00:00
parent 861da51f24
commit 35b954ed36
1 changed files with 6 additions and 2 deletions

View File

@ -435,8 +435,12 @@ class CSVLexer {
}
private void trimTrailingSpaces(StringBuilder buffer) {
while (buffer.length() > 0 && Character.isWhitespace(buffer.charAt(buffer.length() - 1))) {
buffer.setLength(buffer.length() - 1);
int length = buffer.length();
while (length > 0 && Character.isWhitespace(buffer.charAt(length - 1))) {
length = length - 1;
}
if (length != buffer.length()) {
buffer.setLength(length);
}
}