Skip to content

Commit 34b9070

Browse files
committed
Fix #624: try to use more efficient String constructor
1 parent ba02f63 commit 34b9070

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,8 +2434,11 @@ private final String _finishShortText(int len) throws JacksonException
24342434
i = inputBuf[inPtr++];
24352435
outBuf[outPtr++] = (char) i;
24362436
}
2437-
if (inPtr == end && i >= 0) {
2438-
String str = _textBuffer.setCurrentAndReturn(outPtr);
2437+
if (inPtr == end && i >= 0) { // all ASCII
2438+
// 25-Oct-2025: [dataformats-binary#624] Minor optimization: can directly
2439+
// construct String; faster in JDK 17+
2440+
//String str = _textBuffer.setCurrentAndReturn(outPtr);
2441+
String str = _textBuffer.resetWithASCII(inputBuf, inPtr-len, len);
24392442
if (stringRefs != null) {
24402443
stringRefs.stringRefs.add(str);
24412444
_sharedString = str;

0 commit comments

Comments
 (0)