Skip to content

Commit

Permalink
disable int skip map if opt exact max length threshold < 256
Browse files Browse the repository at this point in the history
  • Loading branch information
lopex committed Sep 29, 2018
1 parent 11d8253 commit 495de01
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/org/joni/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public interface Config extends org.jcodings.Config {
final boolean USE_SUNDAY_QUICK_SEARCH = true;
final boolean USE_CEC = false;
final boolean USE_DYNAMIC_OPTION = false;
final boolean USE_BYTE_MAP = OptExactInfo.OPT_EXACT_MAXLEN <= CHAR_TABLE_SIZE;
final boolean USE_INT_MAP_BACKWARD = false;

final int NREGION = 10;
Expand Down
2 changes: 1 addition & 1 deletion src/org/joni/Regex.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ boolean setupBMSkipMap(boolean ignoreCase) {
byte[]buf = new byte[Config.ENC_GET_CASE_FOLD_CODES_MAX_NUM * Config.ENC_MBC_CASE_FOLD_MAXLEN];

final int ilen = USE_SUNDAY_QUICK_SEARCH ? len : len - 1;
if (len < Config.CHAR_TABLE_SIZE) {
if (Config.USE_BYTE_MAP || len < Config.CHAR_TABLE_SIZE) {
if (map == null) map = new byte[Config.CHAR_TABLE_SIZE]; // map/skip
for (int i = 0; i < Config.CHAR_TABLE_SIZE; i++) map[i] = (byte)(USE_SUNDAY_QUICK_SEARCH ? len + 1 : len);

Expand Down
8 changes: 4 additions & 4 deletions src/org/joni/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ final int search(Matcher matcher, byte[]text, int textP, int textEnd, int textRa
}
if (end > textEnd) end = textEnd;

if (regex.intMap == null) {
if (Config.USE_BYTE_MAP || regex.intMap == null) {
while (s < end) {
int p = s;
int t = tail;
Expand Down Expand Up @@ -433,7 +433,7 @@ final int search(Matcher matcher, byte[]text, int textP, int textEnd, int textRa
}
if (end > textEnd) end = textEnd;

if (regex.intMap == null) {
if (Config.USE_BYTE_MAP || regex.intMap == null) {
while (s < end) {
int p = USE_SUNDAY_QUICK_SEARCH ? s - tlen1 : s - (targetEnd - targetP) + 1;
if (lowerCaseMatch(target, targetP, targetEnd, text, p, s + 1, enc, buf, regex.caseFoldFlag)) return p;
Expand Down Expand Up @@ -474,7 +474,7 @@ final int search(Matcher matcher, byte[]text, int textP, int textEnd, int textRa
if (end + tlen1 > textEnd) end = textEnd - tlen1;
int s = textP, p, se;

if (regex.intMap == null) {
if (Config.USE_BYTE_MAP || regex.intMap == null) {
while (s < end) {
p = se = s + tlen1;
int t = tail;
Expand Down Expand Up @@ -531,7 +531,7 @@ final int search(Matcher matcher, byte[]text, int textP, int textEnd, int textRa
if (end + tlen1 > textEnd) end = textEnd - tlen1;
int s = textP;

if (regex.intMap == null) {
if (Config.USE_BYTE_MAP || regex.intMap == null) {
while (s < end) {
int se = s + tlen1;
if (lowerCaseMatch(target, targetP, targetEnd, text, s, se + 1, enc, buf, regex.caseFoldFlag)) return s;
Expand Down

0 comments on commit 495de01

Please sign in to comment.