Skip to content

Commit 19f648d

Browse files
committed
One more simplication from lgtm.com warning
1 parent 95b7620 commit 19f648d

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

smile/src/main/java/com/fasterxml/jackson/dataformat/smile/SmileParserBootstrapper.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ public SmileParser constructParser(int factoryFeatures,
9494
ByteQuadsCanonicalizer can = rootByteSymbols.makeChild(factoryFeatures);
9595
// We just need a single byte, really, to know if it starts with header
9696
int end = _inputEnd;
97-
if (_inputPtr < end && _in != null) {
98-
int count = _in.read(_inputBuffer, end, _inputBuffer.length - end);
99-
if (count > 0) {
97+
if ((_inputPtr < end) && (_in != null)) {
98+
int count = _in.read(_inputBuffer, end, _inputBuffer.length - end);
99+
if (count > 0) {
100100
_inputEnd += count;
101101
}
102102
}
@@ -105,23 +105,23 @@ public SmileParser constructParser(int factoryFeatures,
105105
codec, can,
106106
_in, _inputBuffer, _inputPtr, _inputEnd, _bufferRecyclable);
107107
boolean hadSig = false;
108-
if (_inputPtr < _inputEnd) { // only false for empty doc
109-
if (_inputBuffer[_inputPtr] == SmileConstants.HEADER_BYTE_1) {
110-
// need to ensure it gets properly handled so caller won't see the signature
111-
hadSig = p.handleSignature(true, true);
112-
}
113-
} else {
114-
/* 11-Oct-2012, tatu: Actually, let's allow empty documents even if
115-
* header signature would otherwise be needed. This is useful for
116-
* JAX-RS provider, empty PUT/POST payloads.
117-
*/
108+
109+
if (_inputPtr >= _inputEnd) { // only the case for empty doc
110+
// 11-Oct-2012, tatu: Actually, let's allow empty documents even if
111+
// header signature would otherwise be needed. This is useful for
112+
// JAX-RS provider, empty PUT/POST payloads.
118113
return p;
119114
}
115+
final byte firstByte = _inputBuffer[_inputPtr];
116+
if (firstByte == SmileConstants.HEADER_BYTE_1) {
117+
// need to ensure it gets properly handled so caller won't see the signature
118+
hadSig = p.handleSignature(true, true);
119+
}
120+
120121
if (!hadSig && SmileParser.Feature.REQUIRE_HEADER.enabledIn(smileFeatures)) {
121122
// Ok, first, let's see if it looks like plain JSON...
122123
String msg;
123124

124-
byte firstByte = (_inputPtr < _inputEnd) ? _inputBuffer[_inputPtr] : 0;
125125
if (firstByte == '{' || firstByte == '[') {
126126
msg = "Input does not start with Smile format header (first byte = 0x"
127127
+Integer.toHexString(firstByte & 0xFF)+") -- rather, it starts with '"+((char) firstByte)

0 commit comments

Comments
 (0)