Skip to content

Commit

Permalink
Couple more lgtm.com fixes (including revising one earlier unsuccessf…
Browse files Browse the repository at this point in the history
…ul fix)
  • Loading branch information
cowtowncoder committed Jan 5, 2021
1 parent 9078ad8 commit a5cdb5b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 33 deletions.
1 change: 1 addition & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Project: aalto-xml
1.2.3 (not yet released)

* Fix minor offset check bug in `AsyncByteArrayScanner`/`AsyncByteBufferScanner`
* Various minor fixes based on lgtm.com suggestions

1.2.2 (14-Sep-2019)

Expand Down
28 changes: 13 additions & 15 deletions src/main/java/com/fasterxml/aalto/in/Utf8Scanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -440,22 +440,20 @@ private void handleNsDeclaration(PName name, byte quoteByte)
++_inputPtr;
}
markLF();
} else {
if (c > 0x7F) {
c = decodeMultiByteChar(c, _inputPtr);
if (c < 0) { // surrogate pair
c = -c;
// Let's add first part right away:
if (attrPtr >= attrBuffer.length) {
_nameBuffer = attrBuffer = DataUtil.growArrayBy(attrBuffer, attrBuffer.length);
}
c -= 0x10000;
attrBuffer[attrPtr++] = (char) (0xD800 | (c >> 10));
c = 0xDC00 | (c & 0x3FF);
}
} else if (c != INT_TAB) {
throwInvalidSpace(c);
} else if (c != INT_TAB) {
throwInvalidSpace(c);
}
} else if (c > 0x7F) {
c = decodeMultiByteChar(c, _inputPtr);
if (c < 0) { // surrogate pair
c = -c;
// Let's add first part right away:
if (attrPtr >= attrBuffer.length) {
_nameBuffer = attrBuffer = DataUtil.growArrayBy(attrBuffer, attrBuffer.length);
}
c -= 0x10000;
attrBuffer[attrPtr++] = (char) (0xD800 | (c >> 10));
c = 0xDC00 | (c & 0x3FF);
}
}
}
Expand Down
26 changes: 11 additions & 15 deletions src/main/java/com/fasterxml/aalto/stax/OutputFactoryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,18 @@ public void configureForSpeed()
/**********************************************************************
*/

/**
* Bottleneck factory method used internally; needs to take care of passing
* proper settings to stream writer.
*
* @param autoCloseOutput Whether writer should automatically close the
* output stream or Writer, when close() is called on stream writer.
*/
// Bottleneck factory method used internally; needs to take care of passing
// proper settings to stream writer.
//
// @param forceAutoClose Whether writer should automatically close the
// output stream or Writer, when close() is called on stream writer.
private XMLStreamWriter2 createSW(OutputStream out, Writer w, String enc,
boolean forceAutoClose)
boolean forceAutoClose)
throws XMLStreamException
{
/* Need to ensure that the configuration object is not shared
* any more; otherwise later changes via factory could be
* visible half-way through output...
*/
// Need to ensure that the configuration object is not shared
// any more; otherwise later changes via factory could be
// visible half-way through output...
WriterConfig cfg = _config.createNonShared();
if (forceAutoClose) {
cfg.doAutoCloseOutput(true);
Expand All @@ -214,9 +211,8 @@ private XMLStreamWriter2 createSW(OutputStream out, Writer w, String enc,
if (enc == null) {
enc = XmlConsts.STAX_DEFAULT_OUTPUT_ENCODING;
} else {
/* Canonical ones are interned, so we may have
* normalized encoding already...
*/
// Canonical ones are interned, so we may have
// normalized encoding already...
if (enc != CharsetNames.CS_UTF8
&& enc != CharsetNames.CS_ISO_LATIN1
&& enc != CharsetNames.CS_US_ASCII) {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/fasterxml/aalto/util/TextBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,13 +459,12 @@ public boolean isAllWhitespace()
return true;
}

/**
/*
* Method that can be used to check if the contents of the buffer end
* in specified String.
*
* @return True if the textual content buffer contains ends with the
* specified String; false otherwise
*/
public boolean endsWith(String str)
{
int segIndex = (_segments == null) ? 0 : _segments.size();
Expand All @@ -488,9 +487,9 @@ public boolean endsWith(String str)
bufIndex = buf.length-1;
}
}

return true;
}
*/

/**
* Note: it is assumed that this method is not used often enough to
Expand Down

0 comments on commit a5cdb5b

Please sign in to comment.