Skip to content

Commit

Permalink
One more simplication from lgtm.com warning
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 8, 2021
1 parent 95b7620 commit 19f648d
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public SmileParser constructParser(int factoryFeatures,
ByteQuadsCanonicalizer can = rootByteSymbols.makeChild(factoryFeatures);
// We just need a single byte, really, to know if it starts with header
int end = _inputEnd;
if (_inputPtr < end && _in != null) {
int count = _in.read(_inputBuffer, end, _inputBuffer.length - end);
if (count > 0) {
if ((_inputPtr < end) && (_in != null)) {
int count = _in.read(_inputBuffer, end, _inputBuffer.length - end);
if (count > 0) {
_inputEnd += count;
}
}
Expand All @@ -105,23 +105,23 @@ public SmileParser constructParser(int factoryFeatures,
codec, can,
_in, _inputBuffer, _inputPtr, _inputEnd, _bufferRecyclable);
boolean hadSig = false;
if (_inputPtr < _inputEnd) { // only false for empty doc
if (_inputBuffer[_inputPtr] == SmileConstants.HEADER_BYTE_1) {
// need to ensure it gets properly handled so caller won't see the signature
hadSig = p.handleSignature(true, true);
}
} else {
/* 11-Oct-2012, tatu: Actually, let's allow empty documents even if
* header signature would otherwise be needed. This is useful for
* JAX-RS provider, empty PUT/POST payloads.
*/

if (_inputPtr >= _inputEnd) { // only the case for empty doc
// 11-Oct-2012, tatu: Actually, let's allow empty documents even if
// header signature would otherwise be needed. This is useful for
// JAX-RS provider, empty PUT/POST payloads.
return p;
}
final byte firstByte = _inputBuffer[_inputPtr];
if (firstByte == SmileConstants.HEADER_BYTE_1) {
// need to ensure it gets properly handled so caller won't see the signature
hadSig = p.handleSignature(true, true);
}

if (!hadSig && SmileParser.Feature.REQUIRE_HEADER.enabledIn(smileFeatures)) {
// Ok, first, let's see if it looks like plain JSON...
String msg;

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

0 comments on commit 19f648d

Please sign in to comment.