Skip to content

Commit

Permalink
Fix #143 (regression, not present in 2.3.3)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 6, 2014
1 parent 12ad423 commit 4ceaba8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
15 changes: 10 additions & 5 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
Project: jackson-core
Version: 2.4.0 (29-May-2014)
Version: 2.4.1 (xx-Jun-2014)

#143: Flaw in `BufferRecycler.allocByteBuffer(int,int)` that results in
performance regression

------------------------------------------------------------------------
=== History: ===
------------------------------------------------------------------------

2.3.0 (29-May-2014)

#121: Increase size of low-level byte[]/char[] input/output buffers
(from 4k->8k for bytes, 2k->4k for chars)
Expand All @@ -8,10 +17,6 @@ Version: 2.4.0 (29-May-2014)
of `String` input as well.
- Refactor `BufferRecycler` to eliminate helper enums

------------------------------------------------------------------------
=== History: ===
------------------------------------------------------------------------

2.3.3 (10-Apr-2014)

No changes since 2.3.2.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/fasterxml/jackson/core/io/IOContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,15 @@ public void releaseNameCopyBuffer(char[] buf) {
/**********************************************************
*/

protected void _verifyAlloc(Object buffer) {
protected final void _verifyAlloc(Object buffer) {
if (buffer != null) { throw new IllegalStateException("Trying to call same allocXxx() method second time"); }
}

protected void _verifyRelease(byte[] toRelease, byte[] src) {
protected final void _verifyRelease(byte[] toRelease, byte[] src) {
if ((toRelease != src) && (toRelease.length <= src.length)) { throw wrongBuf(); }
}

protected void _verifyRelease(char[] toRelease, char[] src) {
protected final void _verifyRelease(char[] toRelease, char[] src) {
if ((toRelease != src) && (toRelease.length <= src.length)) { throw wrongBuf(); }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class BufferRecycler
public final static int CHAR_NAME_COPY_BUFFER = 3; // Temporary buffer for getting name characters

// Buffer lengths, defined in 2.4 (smaller before that)

private final static int[] BYTE_BUFFER_LENGTHS = new int[] { 8000, 8000, 2000, 2000 };
private final static int[] CHAR_BUFFER_LENGTHS = new int[] { 4000, 4000, 200, 200 };

Expand Down Expand Up @@ -87,13 +87,13 @@ public final byte[] allocByteBuffer(int ix) {
}

public byte[] allocByteBuffer(int ix, int minSize) {
final int DEF_SIZE = charBufferLength(ix);
final int DEF_SIZE = byteBufferLength(ix);
if (minSize < DEF_SIZE) {
minSize = DEF_SIZE;
}
byte[] buffer = _byteBuffers[ix];
if (buffer == null || buffer.length < minSize) {
buffer = balloc(byteBufferLength(ix));
buffer = balloc(minSize);
} else {
_byteBuffers[ix] = null;
}
Expand Down

0 comments on commit 4ceaba8

Please sign in to comment.