Skip to content

Commit

Permalink
Remove unnecessary checks wrt #121
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 5, 2021
1 parent b8eba25 commit bfd149a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/ctc/wstx/io/ISOLatinReader.java
Expand Up @@ -111,7 +111,7 @@ public int read(char[] cbuf, int start, int len) throws IOException
if (c <= 0x9F) {
if (c == 0x85) { // NEL, let's convert?
c = CONVERT_NEL_TO;
} else if (c >= 0x7F) { // DEL, ctrl chars
} else { // DEL, ctrl chars
int pos = mByteCount + i;
reportInvalidXml11(c, pos, pos);
}
Expand Down
29 changes: 12 additions & 17 deletions src/main/java/com/ctc/wstx/sr/StreamScanner.java
Expand Up @@ -1334,9 +1334,8 @@ protected int resolveCharOnlyEntity(boolean checkStd)
* the entity), so let's push it back first
*/
--mInputPtr;
/* Shortest valid reference would be 3 chars ('&a;'); which
* would only be legal from an expanded entity...
*/
// Shortest valid reference would be 3 chars ('&a;'); which
// would only be legal from an expanded entity...
if (!ensureInput(6)) {
avail = inputInBuffer();
if (avail < 3) {
Expand All @@ -1349,9 +1348,8 @@ protected int resolveCharOnlyEntity(boolean checkStd)
++mInputPtr;
}

/* Ok, now we have one more character to check, and that's enough
* to determine type decisively.
*/
// Ok, now we have one more character to check, and that's enough
// to determine type decisively.
char c = mInputBuffer[mInputPtr];

// A char reference?
Expand Down Expand Up @@ -1381,15 +1379,15 @@ protected int resolveCharOnlyEntity(boolean checkStd)
}
}
} else if (c == 'l') {
if (avail >= 3
&& mInputBuffer[mInputPtr+1] == 't'
// guaranteed at least 3 minimum so
if (mInputBuffer[mInputPtr+1] == 't'
&& mInputBuffer[mInputPtr+2] == ';') {
mInputPtr += 3;
return '<';
}
} else if (c == 'g') {
if (avail >= 3
&& mInputBuffer[mInputPtr+1] == 't'
// guaranteed at least 3 minimum so
if (mInputBuffer[mInputPtr+1] == 't'
&& mInputBuffer[mInputPtr+2] == ';') {
mInputPtr += 3;
return '>';
Expand Down Expand Up @@ -1474,14 +1472,14 @@ protected EntityDecl resolveNonCharEntity()
}
}
} else if (c == 'l') {
if (avail >= 3
&& mInputBuffer[mInputPtr+1] == 't'
// guaranteed at least 3 minimum so
if (mInputBuffer[mInputPtr+1] == 't'
&& mInputBuffer[mInputPtr+2] == ';') {
return null;
}
} else if (c == 'g') {
if (avail >= 3
&& mInputBuffer[mInputPtr+1] == 't'
// guaranteed at least 3 minimum so
if (mInputBuffer[mInputPtr+1] == 't'
&& mInputBuffer[mInputPtr+2] == ';') {
return null;
}
Expand Down Expand Up @@ -2229,9 +2227,6 @@ protected final String parsePublicId(char quoteChar, String errorMsg)
* white space, and coalescing remaining ws into single spaces.
*/
if (spaceToAdd) { // pending white space to add?
if (c == CHAR_SPACE) { // still a space; let's skip
continue;
}
/* ok: if we have non-space, we'll either forget about
* space(s) (if nothing has been output, ie. leading space),
* or output a single space (in-between non-white space)
Expand Down

0 comments on commit bfd149a

Please sign in to comment.