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
lucene/core/src/java/org/apache/lucene/util/fst
|
@ -771,16 +771,14 @@ public final class Util {
|
|||
* IntsRef. */
|
||||
public static IntsRef toUTF16(CharSequence s, IntsRef scratch) {
|
||||
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.length = idx;
|
||||
scratch.length = charLimit;
|
||||
scratch.grow(charLimit);
|
||||
for (int idx = 0; idx < charLimit; idx++) {
|
||||
scratch.ints[idx] = (int) s.charAt(idx);
|
||||
}
|
||||
return scratch;
|
||||
}
|
||||
}
|
||||
|
||||
/** Decodes the Unicode codepoints from the provided
|
||||
* CharSequence and places them in the provided scratch
|
||||
|
|
Loading…
Reference in New Issue