[indexes] skip useless byte[] allocation/copy

+ directly use byte[] subrange instead of its copy

GitOrigin-RevId: be7ea5c8763e69afa1410171856bb0389f34d434
This commit is contained in:
Ruslan Cheremin
2024-07-31 11:29:15 +00:00
committed by intellij-monorepo-bot
parent c7bd7dab06
commit c8a7a4ed29
2 changed files with 10 additions and 1 deletions
@@ -268,6 +268,7 @@ internal fun capturePropagationContext(r: Runnable, forceUseContextJob : Boolean
}
val (childContext, childContinuation) =
if (forceUseContextJob) createChildContextWithContextJob(r.toString())
//TODO: do we really need .toString() here? It allocates ~6 Gb during indexing
else createChildContext(r.toString())
command = ContextRunnable(true, childContext, command)
if (childContinuation != null) {
@@ -117,6 +117,14 @@ public interface DataExternalizerEx<T> {
return new ByteArrayWriter(bytes, 0, bytes.length);
}
static KnownSizeRecordWriter fromBytes(@NotNull ByteArraySequence bytes) {
return new ByteArrayWriter(
bytes.getInternalBuffer(),
bytes.getOffset(),
bytes.getLength()
);
}
static KnownSizeRecordWriter fromBytes(byte @NotNull [] bytes,
int offset,
int length) {
@@ -161,7 +169,7 @@ public interface DataExternalizerEx<T> {
@Override
public String toString() {
return "ByteArrayWriter[" + IOUtil.toHexString(Arrays.copyOfRange(bytes, startingOffset, startingOffset+length)) + "]";
return "ByteArrayWriter[" + IOUtil.toHexString(Arrays.copyOfRange(bytes, startingOffset, startingOffset + length)) + "]";
}
}
}