Skip to content

Commit 719ab03

Browse files
committed
optimized char check for 'eE'
1 parent 8df00ed commit 719ab03

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ protected final JsonToken _parseUnsignedNumber(int ch) throws IOException
14181418
}
14191419
++intLen;
14201420
}
1421-
if (ch == INT_PERIOD || ch == INT_e || ch == INT_E) {
1421+
if (ch == INT_PERIOD || (ch | 0x20) == INT_e) { // ~ '.eE'
14221422
_inputPtr = ptr;
14231423
return _parseFloat(ch, startPtr, ptr, false, intLen);
14241424
}
@@ -1462,7 +1462,7 @@ private final JsonToken _parseFloat(int ch, int startPtr, int ptr, boolean neg,
14621462
}
14631463
}
14641464
int expLen = 0;
1465-
if (ch == 'e' || ch == 'E') { // and/or exponent
1465+
if ((ch | 0x20) == INT_e) { // ~ 'eE' and/or exponent
14661466
if (ptr >= inputLen) {
14671467
_inputPtr = startPtr;
14681468
return _parseNumber2(neg, startPtr);
@@ -1541,7 +1541,7 @@ private final JsonToken _parseSignedNumber(final boolean negative) throws IOExce
15411541
++intLen;
15421542
}
15431543

1544-
if (ch == INT_PERIOD || ch == INT_e || ch == INT_E) {
1544+
if (ch == INT_PERIOD || (ch | 0x20) == INT_e) { // ~ '.eE'
15451545
_inputPtr = ptr;
15461546
return _parseFloat(ch, startPtr, ptr, negative, intLen);
15471547
}
@@ -1653,7 +1653,7 @@ private final JsonToken _parseNumber2(boolean neg, int startPtr) throws IOExcept
16531653
}
16541654

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

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -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

+4-4
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,7 @@ protected JsonToken _parseUnsignedNumber(int c) throws IOException
15071507
++intLen;
15081508
outBuf[outPtr++] = (char) c;
15091509
}
1510-
if (c == INT_PERIOD || c == INT_e || c == INT_E) {
1510+
if (c == INT_PERIOD || (c | 0x20) == INT_e) { // ~ '.eE'
15111511
return _parseFloat(outBuf, outPtr, c, false, intLen);
15121512
}
15131513
--_inputPtr; // to push back trailing char (comma etc)
@@ -1568,7 +1568,7 @@ private final JsonToken _parseSignedNumber(boolean negative) throws IOException
15681568
++intLen;
15691569
outBuf[outPtr++] = (char) c;
15701570
}
1571-
if (c == INT_PERIOD || c == INT_e || c == INT_E) {
1571+
if (c == INT_PERIOD || (c | 0x20) == INT_e) { // ~ '.eE'
15721572
return _parseFloat(outBuf, outPtr, c, negative, intLen);
15731573
}
15741574

@@ -1596,7 +1596,7 @@ private final JsonToken _parseNumber2(char[] outBuf, int outPtr, boolean negativ
15961596
}
15971597
int c = (int) _inputBuffer[_inputPtr++] & 0xFF;
15981598
if (c > INT_9 || c < INT_0) {
1599-
if (c == INT_PERIOD || c == INT_e || c == INT_E) {
1599+
if (c == INT_PERIOD || (c | 0x20) == INT_e) { // ~ '.eE'
16001600
return _parseFloat(outBuf, outPtr, c, negative, intPartLength);
16011601
}
16021602
break;
@@ -1695,7 +1695,7 @@ private final JsonToken _parseFloat(char[] outBuf, int outPtr, int c,
16951695
}
16961696

16971697
int expLen = 0;
1698-
if (c == INT_e || c == INT_E) { // exponent?
1698+
if ((c | 0x20) == INT_e) { // ~ 'eE' exponent?
16991699
if (outPtr >= outBuf.length) {
17001700
outBuf = _textBuffer.finishCurrentSegment();
17011701
outPtr = 0;

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ protected JsonToken _startPositiveNumber(int ch) throws IOException
13131313
break;
13141314
}
13151315
if (ch > INT_9) {
1316-
if (ch == INT_e || ch == INT_E) {
1316+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
13171317
_intLength = outPtr;
13181318
++_inputPtr;
13191319
return _startFloat(outBuf, outPtr, ch);
@@ -1382,7 +1382,7 @@ protected JsonToken _startNegativeNumber() throws IOException
13821382
break;
13831383
}
13841384
if (ch > INT_9) {
1385-
if (ch == INT_e || ch == INT_E) {
1385+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
13861386
_intLength = outPtr-1;
13871387
++_inputPtr;
13881388
return _startFloat(outBuf, outPtr, ch);
@@ -1458,7 +1458,7 @@ protected JsonToken _startPositiveNumber() throws IOException
14581458
break;
14591459
}
14601460
if (ch > INT_9) {
1461-
if (ch == INT_e || ch == INT_E) {
1461+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
14621462
_intLength = outPtr-1;
14631463
++_inputPtr;
14641464
return _startFloat(outBuf, outPtr, ch);
@@ -1505,7 +1505,7 @@ protected JsonToken _startNumberLeadingZero() throws IOException
15051505
return _startFloat(outBuf, 1, ch);
15061506
}
15071507
} else if (ch > INT_9) {
1508-
if (ch == INT_e || ch == INT_E) {
1508+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
15091509
_inputPtr = ptr;
15101510
_intLength = 1;
15111511
char[] outBuf = _textBuffer.emptyAndGetCurrentSegment();
@@ -1608,7 +1608,7 @@ protected JsonToken _finishNumberLeadingZeroes() throws IOException
16081608
return _startFloat(outBuf, 1, ch);
16091609
}
16101610
} else if (ch > INT_9) {
1611-
if (ch == INT_e || ch == INT_E) {
1611+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
16121612
char[] outBuf = _textBuffer.emptyAndGetCurrentSegment();
16131613
outBuf[0] = '0';
16141614
_intLength = 1;
@@ -1668,7 +1668,7 @@ protected JsonToken _finishNumberLeadingPosNegZeroes(final boolean negative) thr
16681668
return _startFloat(outBuf, 2, ch);
16691669
}
16701670
} else if (ch > INT_9) {
1671-
if (ch == INT_e || ch == INT_E) {
1671+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
16721672
char[] outBuf = _textBuffer.emptyAndGetCurrentSegment();
16731673
outBuf[0] = negative ? '-' : '+';
16741674
outBuf[1] = '0';
@@ -1723,7 +1723,7 @@ protected JsonToken _finishNumberIntegralPart(char[] outBuf, int outPtr) throws
17231723
break;
17241724
}
17251725
if (ch > INT_9) {
1726-
if (ch == INT_e || ch == INT_E) {
1726+
if ((ch | 0x20) == INT_e) { // ~ 'eE'
17271727
_intLength = outPtr+negMod;
17281728
++_inputPtr;
17291729
return _startFloat(outBuf, outPtr, ch);
@@ -1779,7 +1779,7 @@ protected JsonToken _startFloat(char[] outBuf, int outPtr, int ch) throws IOExce
17791779
}
17801780
_fractLength = fractLen;
17811781
int expLen = 0;
1782-
if (ch == INT_e || ch == INT_E) { // exponent?
1782+
if ((ch | 0x20) == INT_e) { // ~ 'eE' exponent?
17831783
if (outPtr >= outBuf.length) {
17841784
outBuf = _textBuffer.expandCurrentSegment();
17851785
}
@@ -1878,7 +1878,7 @@ protected JsonToken _finishFloatFraction() throws IOException
18781878
_textBuffer.setCurrentLength(outPtr);
18791879

18801880
// Ok: end of floating point number or exponent?
1881-
if (ch == INT_e || ch == INT_E) { // exponent?
1881+
if ((ch | 0x20) == INT_e) { // ~ 'eE' exponent?
18821882
_textBuffer.append((char) ch);
18831883
_expLength = 0;
18841884
if (_inputPtr >= _inputEnd) {

0 commit comments

Comments
 (0)