Commit 51d3626c authored by Stephane Nicoll's avatar Stephane Nicoll

Merge branch '2.0.x' into 2.1.x

parents 210d1f6d 8d0ad03b
...@@ -66,6 +66,9 @@ final class StringSequence implements CharSequence { ...@@ -66,6 +66,9 @@ final class StringSequence implements CharSequence {
if (subSequenceEnd > this.end) { if (subSequenceEnd > this.end) {
throw new StringIndexOutOfBoundsException(end); throw new StringIndexOutOfBoundsException(end);
} }
if (start == 0 && subSequenceEnd == this.end) {
return this;
}
return new StringSequence(this.source, subSequenceStart, subSequenceEnd); return new StringSequence(this.source, subSequenceStart, subSequenceEnd);
} }
...@@ -100,10 +103,18 @@ final class StringSequence implements CharSequence { ...@@ -100,10 +103,18 @@ final class StringSequence implements CharSequence {
} }
public boolean startsWith(CharSequence prefix, int offset) { public boolean startsWith(CharSequence prefix, int offset) {
if (length() - prefix.length() - offset < 0) { int prefixLength = prefix.length();
if (length() - prefixLength - offset < 0) {
return false; return false;
} }
return subSequence(offset, offset + prefix.length()).equals(prefix); int prefixOffset = 0;
int sourceOffset = offset;
while (prefixLength-- != 0) {
if (charAt(sourceOffset++) != prefix.charAt(prefixOffset++)) {
return false;
}
}
return true;
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment