Skip to content

Commit

Permalink
Update release notes, minor naming wrt #220
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 4, 2025
1 parent b0a292e commit 24a7585
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
5 changes: 5 additions & 0 deletions release-notes/CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,8 @@ Philipp Nanz (@philippn)
(7.1.0)
* Contributed #211: Disable `resolveEntityReferences` by default for newly created SAX parsers
(7.1.0)

Winfried Gerlach (@winfriedgerlach)

* Contributed #220: Switch to lookup tables in hotspots `isNameChar()`/`isNameStartChar()`
(7.1.1)
2 changes: 1 addition & 1 deletion release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Project: woodstox
#213: SAX: `Locator#getSystemId` and `Locator#getPublicId` are not
available during `startDocument` event
(fix contributed by Philipp N)
#221: Switch to lookup tables in hotspots `isNameChar()`/`isNameStartChar()`
#220: Switch to lookup tables in hotspots `isNameChar()`/`isNameStartChar()`
(contributed by @winfriedgerlach)

7.1.0 (22-Oct-2024)
Expand Down
28 changes: 15 additions & 13 deletions src/main/java/com/ctc/wstx/io/WstxInputData.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,23 @@ public class WstxInputData
*/
public final static int MAX_UNICODE_CHAR = 0x10FFFF;

private static final boolean[] asciiNameStartChars = new boolean[128];
// @since 7.1.1
private static final boolean[] ASCII_NAME_START_CHARS = new boolean[128];
static {
IntStream.rangeClosed('a', 'z').forEach(i -> asciiNameStartChars[i] = true);
IntStream.rangeClosed('A', 'Z').forEach(i -> asciiNameStartChars[i] = true);
asciiNameStartChars['_'] = true;
IntStream.rangeClosed('a', 'z').forEach(i -> ASCII_NAME_START_CHARS[i] = true);
IntStream.rangeClosed('A', 'Z').forEach(i -> ASCII_NAME_START_CHARS[i] = true);
ASCII_NAME_START_CHARS['_'] = true;
}

private static final boolean[] asciiNameChars = new boolean[128];
// @since 7.1.1
private static final boolean[] ASCII_NAME_CHARS = new boolean[128];
static {
IntStream.rangeClosed('a', 'z').forEach(i -> asciiNameChars[i] = true);
IntStream.rangeClosed('A', 'Z').forEach(i -> asciiNameChars[i] = true);
IntStream.rangeClosed('0', '9').forEach(i -> asciiNameChars[i] = true);
asciiNameChars['.'] = true;
asciiNameChars['-'] = true;
asciiNameChars['_'] = true;
IntStream.rangeClosed('a', 'z').forEach(i -> ASCII_NAME_CHARS[i] = true);
IntStream.rangeClosed('A', 'Z').forEach(i -> ASCII_NAME_CHARS[i] = true);
IntStream.rangeClosed('0', '9').forEach(i -> ASCII_NAME_CHARS[i] = true);
ASCII_NAME_CHARS['.'] = true;
ASCII_NAME_CHARS['-'] = true;
ASCII_NAME_CHARS['_'] = true;
}

/*
Expand Down Expand Up @@ -174,7 +176,7 @@ protected final boolean isNameStartChar(char c)
*/
if (c < 128) {
// this is performance critical, so we use a lookup table instead of if-branches
return asciiNameStartChars[c];
return ASCII_NAME_START_CHARS[c];
}
/* Ok, otherwise need to use a big honking bit sets... which
* differ between 1.0 and 1.1
Expand All @@ -194,7 +196,7 @@ protected final boolean isNameChar(char c)
// First, let's handle 7-bit ascii range
if (c < 128) {
// this is performance critical, so we use a lookup table instead of if-branches
return asciiNameChars[c];
return ASCII_NAME_CHARS[c];
}
return mXml11 ? XmlChars.is11NameChar(c) : XmlChars.is10NameChar(c);
}
Expand Down

0 comments on commit 24a7585

Please sign in to comment.