Skip to content

Commit a5cdb5b

Browse files
committed
Couple more lgtm.com fixes (including revising one earlier unsuccessful fix)
1 parent 9078ad8 commit a5cdb5b

File tree

4 files changed

+27
-33
lines changed

4 files changed

+27
-33
lines changed

release-notes/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Project: aalto-xml
77
1.2.3 (not yet released)
88

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

1112
1.2.2 (14-Sep-2019)
1213

src/main/java/com/fasterxml/aalto/in/Utf8Scanner.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -440,22 +440,20 @@ private void handleNsDeclaration(PName name, byte quoteByte)
440440
++_inputPtr;
441441
}
442442
markLF();
443-
} else {
444-
if (c > 0x7F) {
445-
c = decodeMultiByteChar(c, _inputPtr);
446-
if (c < 0) { // surrogate pair
447-
c = -c;
448-
// Let's add first part right away:
449-
if (attrPtr >= attrBuffer.length) {
450-
_nameBuffer = attrBuffer = DataUtil.growArrayBy(attrBuffer, attrBuffer.length);
451-
}
452-
c -= 0x10000;
453-
attrBuffer[attrPtr++] = (char) (0xD800 | (c >> 10));
454-
c = 0xDC00 | (c & 0x3FF);
455-
}
456-
} else if (c != INT_TAB) {
457-
throwInvalidSpace(c);
443+
} else if (c != INT_TAB) {
444+
throwInvalidSpace(c);
445+
}
446+
} else if (c > 0x7F) {
447+
c = decodeMultiByteChar(c, _inputPtr);
448+
if (c < 0) { // surrogate pair
449+
c = -c;
450+
// Let's add first part right away:
451+
if (attrPtr >= attrBuffer.length) {
452+
_nameBuffer = attrBuffer = DataUtil.growArrayBy(attrBuffer, attrBuffer.length);
458453
}
454+
c -= 0x10000;
455+
attrBuffer[attrPtr++] = (char) (0xD800 | (c >> 10));
456+
c = 0xDC00 | (c & 0x3FF);
459457
}
460458
}
461459
}

src/main/java/com/fasterxml/aalto/stax/OutputFactoryImpl.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -188,21 +188,18 @@ public void configureForSpeed()
188188
/**********************************************************************
189189
*/
190190

191-
/**
192-
* Bottleneck factory method used internally; needs to take care of passing
193-
* proper settings to stream writer.
194-
*
195-
* @param autoCloseOutput Whether writer should automatically close the
196-
* output stream or Writer, when close() is called on stream writer.
197-
*/
191+
// Bottleneck factory method used internally; needs to take care of passing
192+
// proper settings to stream writer.
193+
//
194+
// @param forceAutoClose Whether writer should automatically close the
195+
// output stream or Writer, when close() is called on stream writer.
198196
private XMLStreamWriter2 createSW(OutputStream out, Writer w, String enc,
199-
boolean forceAutoClose)
197+
boolean forceAutoClose)
200198
throws XMLStreamException
201199
{
202-
/* Need to ensure that the configuration object is not shared
203-
* any more; otherwise later changes via factory could be
204-
* visible half-way through output...
205-
*/
200+
// Need to ensure that the configuration object is not shared
201+
// any more; otherwise later changes via factory could be
202+
// visible half-way through output...
206203
WriterConfig cfg = _config.createNonShared();
207204
if (forceAutoClose) {
208205
cfg.doAutoCloseOutput(true);
@@ -214,9 +211,8 @@ private XMLStreamWriter2 createSW(OutputStream out, Writer w, String enc,
214211
if (enc == null) {
215212
enc = XmlConsts.STAX_DEFAULT_OUTPUT_ENCODING;
216213
} else {
217-
/* Canonical ones are interned, so we may have
218-
* normalized encoding already...
219-
*/
214+
// Canonical ones are interned, so we may have
215+
// normalized encoding already...
220216
if (enc != CharsetNames.CS_UTF8
221217
&& enc != CharsetNames.CS_ISO_LATIN1
222218
&& enc != CharsetNames.CS_US_ASCII) {

src/main/java/com/fasterxml/aalto/util/TextBuilder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,12 @@ public boolean isAllWhitespace()
459459
return true;
460460
}
461461

462-
/**
462+
/*
463463
* Method that can be used to check if the contents of the buffer end
464464
* in specified String.
465465
*
466466
* @return True if the textual content buffer contains ends with the
467467
* specified String; false otherwise
468-
*/
469468
public boolean endsWith(String str)
470469
{
471470
int segIndex = (_segments == null) ? 0 : _segments.size();
@@ -488,9 +487,9 @@ public boolean endsWith(String str)
488487
bufIndex = buf.length-1;
489488
}
490489
}
491-
492490
return true;
493491
}
492+
*/
494493

495494
/**
496495
* Note: it is assumed that this method is not used often enough to

0 commit comments

Comments
 (0)