commit 702c495e98a30d4345884617b986b44d1f90ec11
Author: Kornel Benko <[email protected]>
Date:   Tue Nov 13 12:11:33 2018 +0100

    FindAdv: Significantly increase the search speed
    
    The needed time to find a simple string dependes on the
    paragraph length was O(n^2)
    Now it is down to O(n).
    Before:
        To determine if the pattern matches we compared the
        paragraph from current position to the its end.
        Increment current position if no match
    Now:
        Check if the character at current position has at least
        the needed features (text, color, language etc)
        If not, Increment current position
        else proceed as before
---
 src/lyxfind.cpp |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 6cc57f4..2fd36e2 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -1630,7 +1630,7 @@ void LatexInfo::buildKeys(bool isPatternString)
   // No split
   makeKey("backslash|textbackslash|textasciicircum|textasciitilde|ldots", 
KeyInfo(KeyInfo::isChar, 1, false), isPatternString);
   // Found in fr/UserGuide.lyx
-  makeKey("og|fg", KeyInfo(KeyInfo::isChar, 0, false), isPatternString);
+  makeKey("og|fg|textvisiblespace", KeyInfo(KeyInfo::isChar, 0, false), 
isPatternString);
 
   // Known macros to remove (including their parameter)
   // No split
@@ -2281,6 +2281,8 @@ static int computeSize(string s, int len)
                                                        skip++;
                                                else if ((s[i+j] == '{') && 
s[i+j+1] == '}')
                                                        skip += 2;
+                                               else if ((s[i+j] == '{') && (i 
+ j + 1 >= len))
+                                                       skip++;
                                                break;
                                        }
                                        skip++;
@@ -2693,6 +2695,9 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & 
match)
                        int match_len_zero_count = 0;
                        for (; !theApp()->longOperationCancelled() && cur; 
cur.forwardPos()) {
                                LYXERR(Debug::FIND, "Advancing cur: " << cur);
+                               int match_len3 = match(cur, 1);
+                               if (match_len3 < 0)
+                                       continue;
                                int match_len2 = match(cur);
                                LYXERR(Debug::FIND, "match_len2: " << 
match_len2);
                                if (match_len2 > 0) {

Reply via email to