Skip to content

Commit bc11f42

Browse files
committed
cleanup
1 parent e7b1406 commit bc11f42

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

src/main/java/org/htmlunit/cyberneko/HTMLScanner.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,11 +1096,11 @@ else if (ch1 == '/' && str.charAt(0) == '/') {
10961096

10971097
// Modifies the given name based on the specified mode.
10981098
protected static String modifyName(final String name, final short mode) {
1099-
switch (mode) {
1100-
case NAMES_UPPERCASE:
1101-
return name.toUpperCase(Locale.ROOT);
1102-
case NAMES_LOWERCASE:
1103-
return name.toLowerCase(Locale.ROOT);
1099+
if (NAMES_UPPERCASE == mode) {
1100+
return name.toUpperCase(Locale.ROOT);
1101+
}
1102+
if (NAMES_LOWERCASE == mode) {
1103+
return name.toLowerCase(Locale.ROOT);
11041104
}
11051105
return name;
11061106
}
@@ -1554,8 +1554,9 @@ private int returnEntityRefString(final XMLString str, final boolean content) {
15541554
}
15551555

15561556
// Returns true if the specified text is present (case-insensitive) and is skipped.
1557-
protected boolean skip(final String s) throws IOException {
1558-
final int length = s != null ? s.length() : 0;
1557+
// for performance reasons you have to provide the specified text in uppercase
1558+
protected boolean skip(final String expectedInUpperCase) throws IOException {
1559+
final int length = expectedInUpperCase != null ? expectedInUpperCase.length() : 0;
15591560
for (int i = 0; i < length; i++) {
15601561
if (fCurrentEntity.offset_ == fCurrentEntity.length_) {
15611562
System.arraycopy(fCurrentEntity.buffer_, fCurrentEntity.offset_ - i, fCurrentEntity.buffer_, 0, i);
@@ -1564,10 +1565,8 @@ protected boolean skip(final String s) throws IOException {
15641565
return false;
15651566
}
15661567
}
1567-
char c0 = s.charAt(i);
1568-
char c1 = fCurrentEntity.getNextChar();
1569-
c0 = String.valueOf(c0).toUpperCase(Locale.ROOT).charAt(0);
1570-
c1 = String.valueOf(c1).toUpperCase(Locale.ROOT).charAt(0);
1568+
final char c0 = expectedInUpperCase.charAt(i);
1569+
final char c1 = Character.toUpperCase(fCurrentEntity.getNextChar());
15711570
if (c0 != c1) {
15721571
fCurrentEntity.rewind(i + 1);
15731572
return false;
@@ -2199,9 +2198,7 @@ else if (ename != null) {
21992198
if (fInsertDoctype_) {
22002199
String root = htmlConfiguration_.getHtmlElements().getElement(HTMLElements.HTML).name;
22012200
root = modifyName(root, fNamesElems);
2202-
final String pubid = fDoctypePubid;
2203-
final String sysid = fDoctypeSysid;
2204-
fDocumentHandler.doctypeDecl(root, pubid, sysid, synthesizedAugs());
2201+
fDocumentHandler.doctypeDecl(root, fDoctypePubid, fDoctypeSysid, synthesizedAugs());
22052202
}
22062203
setScannerState(STATE_CONTENT);
22072204
break;

0 commit comments

Comments
 (0)