Skip to content

Commit 1ad7293

Browse files
committed
Merge branch 'CHECK_CHAR_OPTIMIZED' of https://github.com/xtonik/jackson-core into xtonik-CHECK_CHAR_OPTIMIZED
2 parents 3502839 + 9bcffbb commit 1ad7293

File tree

4 files changed

+42
-42
lines changed

4 files changed

+42
-42
lines changed

src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ public final JsonToken nextToken() throws IOException
713713
_binaryValue = null;
714714

715715
// Closing scope?
716-
if (i == INT_RBRACKET || i == INT_RCURLY) {
716+
if ((i | 0x20) == INT_RCURLY) { // ~ '}]'
717717
_closeScope(i);
718718
return _currToken;
719719
}
@@ -724,7 +724,7 @@ public final JsonToken nextToken() throws IOException
724724

725725
// Was that a trailing comma?
726726
if ((_features & FEAT_MASK_TRAILING_COMMA) != 0) {
727-
if ((i == INT_RBRACKET) || (i == INT_RCURLY)) {
727+
if ((i | 0x20) == INT_RCURLY) { // ~ '}]'
728728
_closeScope(i);
729729
return _currToken;
730730
}
@@ -875,7 +875,7 @@ public boolean nextFieldName(SerializableString sstr) throws IOException
875875
_binaryValue = null;
876876

877877
// Closing scope?
878-
if (i == INT_RBRACKET || i == INT_RCURLY) {
878+
if ((i | 0x20) == INT_RCURLY) { // ~ '}]'
879879
_closeScope(i);
880880
return false;
881881
}
@@ -885,7 +885,7 @@ public boolean nextFieldName(SerializableString sstr) throws IOException
885885

886886
// Was that a trailing comma?
887887
if ((_features & FEAT_MASK_TRAILING_COMMA) != 0) {
888-
if ((i == INT_RBRACKET) || (i == INT_RCURLY)) {
888+
if ((i | 0x20) == INT_RCURLY) { // ~ '}]'
889889
_closeScope(i);
890890
return false;
891891
}
@@ -949,14 +949,14 @@ public String nextFieldName() throws IOException
949949
return null;
950950
}
951951
_binaryValue = null;
952-
if (i == INT_RBRACKET || i == INT_RCURLY) {
952+
if ((i | 0x20) == INT_RCURLY) { // ~ '}]'
953953
_closeScope(i);
954954
return null;
955955
}
956956
if (_parsingContext.expectComma()) {
957957
i = _skipComma(i);
958958
if ((_features & FEAT_MASK_TRAILING_COMMA) != 0) {
959-
if ((i == INT_RBRACKET) || (i == INT_RCURLY)) {
959+
if ((i | 0x20) == INT_RCURLY) { // ~ '}]'
960960
_closeScope(i);
961961
return null;
962962
}
@@ -1417,7 +1417,7 @@ protected final JsonToken _parseUnsignedNumber(int ch) throws IOException
14171417
}
14181418
++intLen;
14191419
}
1420-
if (ch == INT_PERIOD || ch == INT_e || ch == INT_E) {
1420+
if (ch == INT_PERIOD || (ch | 0x20) == INT_e) { // ~ '.eE'
14211421
_inputPtr = ptr;
14221422
return _parseFloat(ch, startPtr, ptr, false, intLen);
14231423
}
@@ -1460,7 +1460,7 @@ private final JsonToken _parseFloat(int ch, int startPtr, int ptr, boolean neg,
14601460
}
14611461
}
14621462
int expLen = 0;
1463-
if (ch == 'e' || ch == 'E') { // and/or exponent
1463+
if ((ch | 0x20) == INT_e) { // ~ 'eE' and/or exponent
14641464
if (ptr >= inputLen) {
14651465
_inputPtr = startPtr;
14661466
return _parseNumber2(neg, startPtr);
@@ -1538,7 +1538,7 @@ private final JsonToken _parseSignedNumber(final boolean negative) throws IOExce
15381538
++intLen;
15391539
}
15401540

1541-
if (ch == INT_PERIOD || ch == INT_e || ch == INT_E) {
1541+
if (ch == INT_PERIOD || (ch | 0x20) == INT_e) { // ~ '.eE'
15421542
_inputPtr = ptr;
15431543
return _parseFloat(ch, startPtr, ptr, negative, intLen);
15441544
}
@@ -1649,7 +1649,7 @@ private final JsonToken _parseNumber2(boolean neg, int startPtr) throws IOExcept
16491649
}
16501650

16511651
int expLen = -1;
1652-
if (c == 'e' || c == 'E') { // exponent?
1652+
if ((c | 0x20) == INT_e) { // ~ 'eE' exponent?
16531653
expLen = 0;
16541654
if (outPtr >= outBuf.length) {
16551655
outBuf = _textBuffer.finishCurrentSegment();

src/main/java/com/fasterxml/jackson/core/json/UTF8DataInputJsonParser.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ public JsonToken nextToken() throws IOException
611611
_tokenInputRow = _currInputRow;
612612

613613
// Closing scope?
614-
if (i == INT_RBRACKET || i == INT_RCURLY) {
614+
if ((i | 0x20) == INT_RCURLY) { // ~ '}]'
615615
_closeScope(i);
616616
return _currToken;
617617
}
@@ -625,7 +625,7 @@ public JsonToken nextToken() throws IOException
625625

626626
// Was that a trailing comma?
627627
if ((_features & FEAT_MASK_TRAILING_COMMA) != 0) {
628-
if (i == INT_RBRACKET || i == INT_RCURLY) {
628+
if ((i | 0x20) == INT_RCURLY) { // ~ '}]'
629629
_closeScope(i);
630630
return _currToken;
631631
}
@@ -801,7 +801,7 @@ public String nextFieldName() throws IOException
801801
_binaryValue = null;
802802
_tokenInputRow = _currInputRow;
803803

804-
if (i == INT_RBRACKET || i == INT_RCURLY) {
804+
if ((i | 0x20) == INT_RCURLY) { // ~ '}]'
805805
_closeScope(i);
806806
return null;
807807
}
@@ -815,7 +815,7 @@ public String nextFieldName() throws IOException
815815

816816
// Was that a trailing comma?
817817
if ((_features & FEAT_MASK_TRAILING_COMMA) != 0) {
818-
if (i == INT_RBRACKET || i == INT_RCURLY) {
818+
if ((i | 0x20) == INT_RCURLY) { // ~ '}]'
819819
_closeScope(i);
820820
return null;
821821
}
@@ -1077,7 +1077,7 @@ protected JsonToken _parseUnsignedNumber(int c) throws IOException
10771077
outBuf[outPtr++] = (char) c;
10781078
c = _inputData.readUnsignedByte();
10791079
}
1080-
if (c == '.' || c == 'e' || c == 'E') {
1080+
if (c == '.' || (c | 0x20) == INT_e) { // ~ '.eE'
10811081
return _parseFloat(outBuf, outPtr, c, false, intLen);
10821082
}
10831083
_textBuffer.setCurrentLength(outPtr);
@@ -1140,7 +1140,7 @@ private final JsonToken _parseSignedNumber(boolean negative) throws IOException
11401140
outBuf[outPtr++] = (char) c;
11411141
c = _inputData.readUnsignedByte();
11421142
}
1143-
if (c == '.' || c == 'e' || c == 'E') {
1143+
if (c == '.' || (c | 0x20) == INT_e) { // ~ '.eE'
11441144
return _parseFloat(outBuf, outPtr, c, negative, intLen);
11451145
}
11461146
_textBuffer.setCurrentLength(outPtr);
@@ -1217,7 +1217,7 @@ private final JsonToken _parseFloat(char[] outBuf, int outPtr, int c,
12171217
}
12181218

12191219
int expLen = 0;
1220-
if (c == INT_e || c == INT_E) { // exponent?
1220+
if ((c | 0x20) == INT_e) { // ~ 'eE' exponent?
12211221
if (outPtr >= outBuf.length) {
12221222
outBuf = _textBuffer.finishCurrentSegment();
12231223
outPtr = 0;

src/main/java/com/fasterxml/jackson/core/json/UTF8StreamJsonParser.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ protected JsonToken _parseUnsignedNumber(int c) throws IOException
15041504
++intLen;
15051505
outBuf[outPtr++] = (char) c;
15061506
}
1507-
if (c == INT_PERIOD || c == INT_e || c == INT_E) {
1507+
if (c == INT_PERIOD || (c | 0x20) == INT_e) { // ~ '.eE'
15081508
return _parseFloat(outBuf, outPtr, c, false, intLen);
15091509
}
15101510
--_inputPtr; // to push back trailing char (comma etc)
@@ -1565,7 +1565,7 @@ private final JsonToken _parseSignedNumber(boolean negative) throws IOException
15651565
++intLen;
15661566
outBuf[outPtr++] = (char) c;
15671567
}
1568-
if (c == INT_PERIOD || c == INT_e || c == INT_E) {
1568+
if (c == INT_PERIOD || (c | 0x20) == INT_e) { // ~ '.eE'
15691569
return _parseFloat(outBuf, outPtr, c, negative, intLen);
15701570
}
15711571

@@ -1593,7 +1593,7 @@ private final JsonToken _parseNumber2(char[] outBuf, int outPtr, boolean negativ
15931593
}
15941594
int c = (int) _inputBuffer[_inputPtr++] & 0xFF;
15951595
if (c > INT_9 || c < INT_0) {
1596-
if (c == INT_PERIOD || c == INT_e || c == INT_E) {
1596+
if (c == INT_PERIOD || (c | 0x20) == INT_e) { // ~ '.eE'
15971597
return _parseFloat(outBuf, outPtr, c, negative, intPartLength);
15981598
}
15991599
break;
@@ -1691,7 +1691,7 @@ private final JsonToken _parseFloat(char[] outBuf, int outPtr, int c,
16911691
}
16921692

16931693
int expLen = 0;
1694-
if (c == INT_e || c == INT_E) { // exponent?
1694+
if ((c | 0x20) == INT_e) { // ~ 'eE' exponent?
16951695
if (outPtr >= outBuf.length) {
16961696
outBuf = _textBuffer.finishCurrentSegment();
16971697
outPtr = 0;
@@ -2942,7 +2942,7 @@ protected final void _matchTrue() throws IOException
29422942
&& (buf[ptr++] == 'u')
29432943
&& (buf[ptr++] == 'e')) {
29442944
int ch = buf[ptr] & 0xFF;
2945-
if (ch < INT_0 || (ch == INT_RBRACKET) || (ch == INT_RCURLY)) { // expected/allowed chars
2945+
if (ch < INT_0 || (ch | 0x20) == INT_RCURLY) { // < '0' || ~ '}]' expected/allowed chars
29462946
_inputPtr = ptr;
29472947
return;
29482948
}
@@ -2961,7 +2961,7 @@ protected final void _matchFalse() throws IOException
29612961
&& (buf[ptr++] == 's')
29622962
&& (buf[ptr++] == 'e')) {
29632963
int ch = buf[ptr] & 0xFF;
2964-
if (ch < INT_0 || (ch == INT_RBRACKET) || (ch == INT_RCURLY)) { // expected/allowed chars
2964+
if (ch < INT_0 || (ch | 0x20) == INT_RCURLY) { // < '0' || ~ '}]' expected/allowed chars
29652965
_inputPtr = ptr;
29662966
return;
29672967
}
@@ -2979,7 +2979,7 @@ protected final void _matchNull() throws IOException
29792979
&& (buf[ptr++] == 'l')
29802980
&& (buf[ptr++] == 'l')) {
29812981
int ch = buf[ptr] & 0xFF;
2982-
if (ch < INT_0 || (ch == INT_RBRACKET) || (ch == INT_RCURLY)) { // expected/allowed chars
2982+
if (ch < INT_0 || (ch | 0x20) == INT_RCURLY) { // < '0' || ~ '}]' expected/allowed chars
29832983
_inputPtr = ptr;
29842984
return;
29852985
}

src/main/java/com/fasterxml/jackson/core/json/async/NonBlockingUtf8JsonParserBase.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ protected JsonToken _startFalseToken() throws IOException
11071107
&& (getByteFromBuffer(ptr++) == 's')
11081108
&& (getByteFromBuffer(ptr++) == 'e')) {
11091109
int ch = getByteFromBuffer(ptr) & 0xFF;
1110-
if (ch < INT_0 || (ch == INT_RBRACKET) || (ch == INT_RCURLY)) { // expected/allowed chars
1110+
if (ch < INT_0 || (ch | 0x20) == INT_RCURLY) { // < '0' || ~ '}]' expected/allowed chars
11111111
_inputPtr = ptr;
11121112
return _valueComplete(JsonToken.VALUE_FALSE);
11131113
}
@@ -1125,7 +1125,7 @@ protected JsonToken _startTrueToken() throws IOException
11251125
&& (getByteFromBuffer(ptr++) == 'u')
11261126
&& (getByteFromBuffer(ptr++) == 'e')) {
11271127
int ch = getByteFromBuffer(ptr) & 0xFF;
1128-
if (ch < INT_0 || (ch == INT_RBRACKET) || (ch == INT_RCURLY)) { // expected/allowed chars
1128+
if (ch < INT_0 || (ch | 0x20) == INT_RCURLY) { // < '0' || ~ '}]' expected/allowed chars
11291129
_inputPtr = ptr;
11301130
return _valueComplete(JsonToken.VALUE_TRUE);
11311131
}
@@ -1143,7 +1143,7 @@ protected JsonToken _startNullToken() throws IOException
11431143
&& (getByteFromBuffer(ptr++) == 'l')
11441144
&& (getByteFromBuffer(ptr++) == 'l')) {
11451145
int ch = getByteFromBuffer(ptr) & 0xFF;
1146-
if (ch < INT_0 || (ch == INT_RBRACKET) || (ch == INT_RCURLY)) { // expected/allowed chars
1146+
if (ch < INT_0 || (ch | 0x20) == INT_RCURLY) { // < '0' || ~ '}]' expected/allowed chars
11471147
_inputPtr = ptr;
11481148
return _valueComplete(JsonToken.VALUE_NULL);
11491149
}
@@ -1165,7 +1165,7 @@ protected JsonToken _finishKeywordToken(String expToken, int matched,
11651165
}
11661166
int ch = getByteFromBuffer(_inputPtr);
11671167
if (matched == end) { // need to verify trailing separator
1168-
if (ch < INT_0 || (ch == INT_RBRACKET) || (ch == INT_RCURLY)) { // expected/allowed chars
1168+
if (ch < INT_0 || (ch | 0x20) == INT_RCURLY) { // < '0' || ~ '}]' expected/allowed chars
11691169
return _valueComplete(result);
11701170
}
11711171
break;
@@ -1205,7 +1205,7 @@ protected JsonToken _finishNonStdToken(int type, int matched) throws IOException
12051205
}
12061206
int ch = getByteFromBuffer(_inputPtr);
12071207
if (matched == end) { // need to verify trailing separator
1208-
if (ch < INT_0 || (ch == INT_RBRACKET) || (ch == INT_RCURLY)) { // expected/allowed chars
1208+
if (ch < INT_0 || (ch | 0x20) == INT_RCURLY) { // < '0' || ~ '}]' expected/allowed chars
12091209
return _valueNonStdNumberComplete(type);
12101210
}
12111211
break;
@@ -1306,7 +1306,7 @@ protected JsonToken _startPositiveNumber(int ch) throws IOException
13061306
break;
13071307
}
13081308
if (ch > INT_9) {
1309-
if (ch == INT_e || ch == INT_E) {
1309+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
13101310
_intLength = outPtr;
13111311
++_inputPtr;
13121312
return _startFloat(outBuf, outPtr, ch);
@@ -1373,7 +1373,7 @@ protected JsonToken _startNegativeNumber() throws IOException
13731373
break;
13741374
}
13751375
if (ch > INT_9) {
1376-
if (ch == INT_e || ch == INT_E) {
1376+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
13771377
_intLength = outPtr-1;
13781378
++_inputPtr;
13791379
return _startFloat(outBuf, outPtr, ch);
@@ -1445,7 +1445,7 @@ protected JsonToken _startPositiveNumber() throws IOException
14451445
break;
14461446
}
14471447
if (ch > INT_9) {
1448-
if (ch == INT_e || ch == INT_E) {
1448+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
14491449
_intLength = outPtr-1;
14501450
++_inputPtr;
14511451
return _startFloat(outBuf, outPtr, ch);
@@ -1492,7 +1492,7 @@ protected JsonToken _startNumberLeadingZero() throws IOException
14921492
return _startFloat(outBuf, 1, ch);
14931493
}
14941494
} else if (ch > INT_9) {
1495-
if (ch == INT_e || ch == INT_E) {
1495+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
14961496
_inputPtr = ptr;
14971497
_intLength = 1;
14981498
char[] outBuf = _textBuffer.emptyAndGetCurrentSegment();
@@ -1502,7 +1502,7 @@ protected JsonToken _startNumberLeadingZero() throws IOException
15021502
// Ok; unfortunately we have closing bracket/curly that are valid so need
15031503
// (colon not possible since this is within value, not after key)
15041504
//
1505-
if ((ch != INT_RBRACKET) && (ch != INT_RCURLY)) {
1505+
if ((ch | 0x20) != INT_RCURLY) { // ~ '}]'
15061506
_reportUnexpectedNumberChar(ch,
15071507
"expected digit (0-9), decimal point (.) or exponent indicator (e/E) to follow '0'");
15081508
}
@@ -1590,7 +1590,7 @@ protected JsonToken _finishNumberLeadingZeroes() throws IOException
15901590
return _startFloat(outBuf, 1, ch);
15911591
}
15921592
} else if (ch > INT_9) {
1593-
if (ch == INT_e || ch == INT_E) {
1593+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
15941594
char[] outBuf = _textBuffer.emptyAndGetCurrentSegment();
15951595
outBuf[0] = '0';
15961596
_intLength = 1;
@@ -1599,7 +1599,7 @@ protected JsonToken _finishNumberLeadingZeroes() throws IOException
15991599
// Ok; unfortunately we have closing bracket/curly that are valid so need
16001600
// (colon not possible since this is within value, not after key)
16011601
//
1602-
if ((ch != INT_RBRACKET) && (ch != INT_RCURLY)) {
1602+
if ((ch | 0x20) != INT_RCURLY) { // ~ '}]'
16031603
_reportUnexpectedNumberChar(ch,
16041604
"expected digit (0-9), decimal point (.) or exponent indicator (e/E) to follow '0'");
16051605
}
@@ -1649,7 +1649,7 @@ protected JsonToken _finishNumberLeadingPosNegZeroes(final boolean negative) thr
16491649
return _startFloat(outBuf, 2, ch);
16501650
}
16511651
} else if (ch > INT_9) {
1652-
if (ch == INT_e || ch == INT_E) {
1652+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
16531653
char[] outBuf = _textBuffer.emptyAndGetCurrentSegment();
16541654
outBuf[0] = negative ? '-' : '+';
16551655
outBuf[1] = '0';
@@ -1659,7 +1659,7 @@ protected JsonToken _finishNumberLeadingPosNegZeroes(final boolean negative) thr
16591659
// Ok; unfortunately we have closing bracket/curly that are valid so need
16601660
// (colon not possible since this is within value, not after key)
16611661
//
1662-
if ((ch != INT_RBRACKET) && (ch != INT_RCURLY)) {
1662+
if ((ch | 0x20) != INT_RCURLY) { // ~ '}]'
16631663
_reportUnexpectedNumberChar(ch,
16641664
"expected digit (0-9), decimal point (.) or exponent indicator (e/E) to follow '0'");
16651665
}
@@ -1703,7 +1703,7 @@ protected JsonToken _finishNumberIntegralPart(char[] outBuf, int outPtr) throws
17031703
break;
17041704
}
17051705
if (ch > INT_9) {
1706-
if (ch == INT_e || ch == INT_E) {
1706+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
17071707
_intLength = outPtr+negMod;
17081708
++_inputPtr;
17091709
return _startFloat(outBuf, outPtr, ch);
@@ -1758,7 +1758,7 @@ protected JsonToken _startFloat(char[] outBuf, int outPtr, int ch) throws IOExce
17581758
}
17591759
_fractLength = fractLen;
17601760
int expLen = 0;
1761-
if (ch == INT_e || ch == INT_E) { // exponent?
1761+
if ((ch | 0x20) == INT_e) { // ~ 'eE' exponent?
17621762
if (outPtr >= outBuf.length) {
17631763
outBuf = _textBuffer.expandCurrentSegment();
17641764
}
@@ -1833,7 +1833,7 @@ protected JsonToken _finishFloatFraction() throws IOException
18331833
return JsonToken.NOT_AVAILABLE;
18341834
}
18351835
ch = getNextSignedByteFromBuffer();
1836-
} else if (ch == 'f' || ch == 'd' || ch == 'F' || ch == 'D') {
1836+
} else if ((ch | 0x22) == 'f') { // ~ fFdD
18371837
_reportUnexpectedNumberChar(ch, "JSON does not support parsing numbers that have 'f' or 'd' suffixes");
18381838
} else if (ch == INT_PERIOD) {
18391839
_reportUnexpectedNumberChar(ch, "Cannot parse number with more than one decimal point");
@@ -1853,7 +1853,7 @@ protected JsonToken _finishFloatFraction() throws IOException
18531853
_textBuffer.setCurrentLength(outPtr);
18541854

18551855
// Ok: end of floating point number or exponent?
1856-
if (ch == INT_e || ch == INT_E) { // exponent?
1856+
if ((ch | 0x20) == INT_e) { // ~ 'eE' exponent?
18571857
_textBuffer.append((char) ch);
18581858
_expLength = 0;
18591859
if (_inputPtr >= _inputEnd) {

0 commit comments

Comments
 (0)