Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/tools/jackson/core/util/BufferRecycler.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,23 @@ public byte[] allocByteBuffer(int ix, int minSize) {
}
byte[] buffer = _byteBuffers.getAndSet(ix, null);
if (buffer == null || buffer.length < minSize) {
System.err.print(" [Ab"+ix+"]");
buffer = balloc(minSize);
}
else System.err.print(" [Ub"+ix+"]");
return buffer;
}

public void releaseByteBuffer(int ix, byte[] buffer) {
Objects.requireNonNull(buffer);
// 13-Jan-2024, tatu: [core#1186] Replace only if beneficial:
byte[] oldBuffer = _byteBuffers.get(ix);
if ((oldBuffer == null) || buffer.length > oldBuffer.length) {
System.err.print(" [Rb"+ix+"]");
// Could use CAS, but should not really matter
_byteBuffers.set(ix, buffer);
}
else System.err.print(" [FailRb"+ix+"]");
}

/*
Expand All @@ -190,18 +195,23 @@ public char[] allocCharBuffer(int ix, int minSize) {
}
char[] buffer = _charBuffers.getAndSet(ix, null);
if (buffer == null || buffer.length < minSize) {
System.err.print(" [Ac"+ix+"]");
buffer = calloc(minSize);
}
else System.err.print(" [Uc"+ix+"]");
return buffer;
}

public void releaseCharBuffer(int ix, char[] buffer) {
Objects.requireNonNull(buffer);
// 13-Jan-2024, tatu: [core#1186] Replace only if beneficial:
char[] oldBuffer = _charBuffers.get(ix);
if ((oldBuffer == null) || buffer.length > oldBuffer.length) {
System.err.print(" [Rc"+ix+"]");
// Could use CAS, but should not really matter
_charBuffers.set(ix, buffer);
}
else System.err.print(" [FailRc"+ix+"]");
}

/*
Expand Down