mirror of https://github.com/apache/lucene.git
Rewrite the copying loop slightly; scratch.grow has an assert offset == 0
so moved this reset up before grow. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1374431 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9a00dbc928
commit
00f61eb9cb
|
@ -771,14 +771,12 @@ public final class Util {
|
||||||
* IntsRef. */
|
* IntsRef. */
|
||||||
public static IntsRef toUTF16(CharSequence s, IntsRef scratch) {
|
public static IntsRef toUTF16(CharSequence s, IntsRef scratch) {
|
||||||
final int charLimit = s.length();
|
final int charLimit = s.length();
|
||||||
scratch.grow(charLimit);
|
|
||||||
int idx = 0;
|
|
||||||
while(idx < charLimit) {
|
|
||||||
scratch.ints[idx] = (int) s.charAt(idx);
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
scratch.offset = 0;
|
scratch.offset = 0;
|
||||||
scratch.length = idx;
|
scratch.length = charLimit;
|
||||||
|
scratch.grow(charLimit);
|
||||||
|
for (int idx = 0; idx < charLimit; idx++) {
|
||||||
|
scratch.ints[idx] = (int) s.charAt(idx);
|
||||||
|
}
|
||||||
return scratch;
|
return scratch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue