mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
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
This commit is contained in:
parent
1bdba953a5
commit
702c495e98
@ -1630,7 +1630,7 @@ void LatexInfo::buildKeys(bool isPatternString)
|
|||||||
// No split
|
// No split
|
||||||
makeKey("backslash|textbackslash|textasciicircum|textasciitilde|ldots", KeyInfo(KeyInfo::isChar, 1, false), isPatternString);
|
makeKey("backslash|textbackslash|textasciicircum|textasciitilde|ldots", KeyInfo(KeyInfo::isChar, 1, false), isPatternString);
|
||||||
// Found in fr/UserGuide.lyx
|
// 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)
|
// Known macros to remove (including their parameter)
|
||||||
// No split
|
// No split
|
||||||
@ -2281,6 +2281,8 @@ static int computeSize(string s, int len)
|
|||||||
skip++;
|
skip++;
|
||||||
else if ((s[i+j] == '{') && s[i+j+1] == '}')
|
else if ((s[i+j] == '{') && s[i+j+1] == '}')
|
||||||
skip += 2;
|
skip += 2;
|
||||||
|
else if ((s[i+j] == '{') && (i + j + 1 >= len))
|
||||||
|
skip++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
skip++;
|
skip++;
|
||||||
@ -2693,6 +2695,9 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
|||||||
int match_len_zero_count = 0;
|
int match_len_zero_count = 0;
|
||||||
for (; !theApp()->longOperationCancelled() && cur; cur.forwardPos()) {
|
for (; !theApp()->longOperationCancelled() && cur; cur.forwardPos()) {
|
||||||
LYXERR(Debug::FIND, "Advancing cur: " << cur);
|
LYXERR(Debug::FIND, "Advancing cur: " << cur);
|
||||||
|
int match_len3 = match(cur, 1);
|
||||||
|
if (match_len3 < 0)
|
||||||
|
continue;
|
||||||
int match_len2 = match(cur);
|
int match_len2 = match(cur);
|
||||||
LYXERR(Debug::FIND, "match_len2: " << match_len2);
|
LYXERR(Debug::FIND, "match_len2: " << match_len2);
|
||||||
if (match_len2 > 0) {
|
if (match_len2 > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user