mirror of
https://github.com/apache/lucene.git
synced 2025-02-09 19:45:22 +00:00
Use growNoCopy when copying bytes in BytesRefBuilder (#13930)
This commit is contained in:
parent
3983fa2c8d
commit
05e06e51ec
@ -53,6 +53,8 @@ Optimizations
|
|||||||
* GITHUB#13800: MaxScoreBulkScorer now recomputes scorer partitions when the
|
* GITHUB#13800: MaxScoreBulkScorer now recomputes scorer partitions when the
|
||||||
minimum competitive allows for a more favorable partitioning. (Adrien Grand)
|
minimum competitive allows for a more favorable partitioning. (Adrien Grand)
|
||||||
|
|
||||||
|
* GITHUB#13930: Use growNoCopy when copying bytes in BytesRefBuilder. (Ignacio Vera)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
---------------------
|
---------------------
|
||||||
* GITHUB#13832: Fixed an issue where the DefaultPassageFormatter.format method did not format passages as intended
|
* GITHUB#13832: Fixed an issue where the DefaultPassageFormatter.format method did not format passages as intended
|
||||||
|
@ -100,8 +100,10 @@ public class BytesRefBuilder {
|
|||||||
* #clear()} and then {@link #append(byte[], int, int)}.
|
* #clear()} and then {@link #append(byte[], int, int)}.
|
||||||
*/
|
*/
|
||||||
public void copyBytes(byte[] b, int off, int len) {
|
public void copyBytes(byte[] b, int off, int len) {
|
||||||
clear();
|
assert ref.offset == 0;
|
||||||
append(b, off, len);
|
ref.length = len;
|
||||||
|
growNoCopy(len);
|
||||||
|
System.arraycopy(b, off, ref.bytes, 0, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,8 +111,7 @@ public class BytesRefBuilder {
|
|||||||
* #clear()} and then {@link #append(BytesRef)}.
|
* #clear()} and then {@link #append(BytesRef)}.
|
||||||
*/
|
*/
|
||||||
public void copyBytes(BytesRef ref) {
|
public void copyBytes(BytesRef ref) {
|
||||||
clear();
|
copyBytes(ref.bytes, ref.offset, ref.length);
|
||||||
append(ref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,8 +119,7 @@ public class BytesRefBuilder {
|
|||||||
* #clear()} and then {@link #append(BytesRefBuilder)}.
|
* #clear()} and then {@link #append(BytesRefBuilder)}.
|
||||||
*/
|
*/
|
||||||
public void copyBytes(BytesRefBuilder builder) {
|
public void copyBytes(BytesRefBuilder builder) {
|
||||||
clear();
|
copyBytes(builder.get());
|
||||||
append(builder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,7 +135,7 @@ public class BytesRefBuilder {
|
|||||||
* text.
|
* text.
|
||||||
*/
|
*/
|
||||||
public void copyChars(CharSequence text, int off, int len) {
|
public void copyChars(CharSequence text, int off, int len) {
|
||||||
grow(UnicodeUtil.maxUTF8Length(len));
|
growNoCopy(UnicodeUtil.maxUTF8Length(len));
|
||||||
ref.length = UnicodeUtil.UTF16toUTF8(text, off, len, ref.bytes);
|
ref.length = UnicodeUtil.UTF16toUTF8(text, off, len, ref.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ public class BytesRefBuilder {
|
|||||||
* text.
|
* text.
|
||||||
*/
|
*/
|
||||||
public void copyChars(char[] text, int off, int len) {
|
public void copyChars(char[] text, int off, int len) {
|
||||||
grow(UnicodeUtil.maxUTF8Length(len));
|
growNoCopy(UnicodeUtil.maxUTF8Length(len));
|
||||||
ref.length = UnicodeUtil.UTF16toUTF8(text, off, len, ref.bytes);
|
ref.length = UnicodeUtil.UTF16toUTF8(text, off, len, ref.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user