]> gitweb.fperrin.net Git - DictionaryPC.git/commitdiff
Optimize finding start of next token.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Thu, 16 Apr 2020 20:10:03 +0000 (22:10 +0200)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Thu, 16 Apr 2020 20:10:03 +0000 (22:10 +0200)
src/com/hughes/android/dictionary/parser/WikiTokenizer.java

index 0aaf9f6458da8ac16f4561fc5c87d8694eaa8aa2..886e4f9074a20de21b36e6d85199dfa680aa7ca0 100644 (file)
@@ -463,8 +463,15 @@ public final class WikiTokenizer {
             }
 
 
-            if (this.matcher.find(start)) {
-                end = this.matcher.start();
+            while (end < wikiText.length()) {
+                int c = wikiText.charAt(end);
+                if (c == '\n' || c == '\'' || ((c - 0x1b) & 0xff9f) < 3) {
+                    matcher.region(end, wikiText.length());
+                    if (matcher.lookingAt()) break;
+                }
+                end++;
+            }
+            if (end != wikiText.length()) {
                 isPlainText = true;
                 if (end == start) {
                     // stumbled over a new type of newline?
@@ -477,7 +484,6 @@ public final class WikiTokenizer {
                 return this;
             }
 
-            end = wikiText.length();
             isPlainText = true;
             return this;