-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hilightLine speed improvement #28
Conversation
hilightLine now concatenates whole areas delimited by color stack instead of every next character separately
Merged! 👍 |
Hope I won't do any changes till tomorrow :) By the way simple test of matching any not empty line to a file with approx. 300 lines time cgrep --color -r --lang=Cpp -i -P '.+' src/CexmcChargeExchangeReconstructor.cc shows that a new version approx. 3 times faster. And I also found that by some reason
no matter whether |
Another issue I just found. If I have literal cgrep --format='#f ⎜ #n #l' -r "$@" -P '\*' ./src/CGrep/Parser/Cpp/Token.hs will replace line
with
If I do not set any format then cgrep shows original line correctly. |
I'm investigating on the first one right now... On Sat, Oct 31, 2015 at 3:09 PM, Alexey Radkov notifications@github.com
The difference between theory and practice is bigger in practice than in |
I suspect that matching with empty line can make harm to
and this Prelude index error in case of |
Trying to fix the second one right now... |
Alexey, I believe to have fixed both bugs. You can pull from master and check it If everything is fine tomorrow we can release it on hackage. Ciao, On Sat, Oct 31, 2015 at 3:40 PM, Alexey Radkov notifications@github.com
The difference between theory and practice is bigger in practice than in |
Array index error has really gone! But
are still here. And color escape sequences algorithm requires additional patch from me for cases when the match is empty: diff --git a/src/CGrep/Output.hs b/src/CGrep/Output.hs
index d4cf6df..33b4ecd 100644
--- a/src/CGrep/Output.hs
+++ b/src/CGrep/Output.hs
@@ -243,5 +243,5 @@ hilightLine ts = hilightLine' (hilightIndicies ts, 0, 0)
(next, rest) = splitAt nn s
hilightIndicies :: [Token] -> [(Int, Int)]
-hilightIndicies = foldr (\t a -> let b = fst t in (b, b + length (snd t) - 1) : a) []
+hilightIndicies = foldr (\t a -> let b = fst t in (b, b + length (snd t) - 1) : a) [] . filter ((>0) . length . snd) Could you patch it? ... because otherwise I will have to open a new Pull Request. :) |
Hmm. Incredible. Point 1 is an error in PCRE library (or I somehow misunderstand how to use patterns there). Here is a part of my ghci session.
So this point is not related to cgrep. |
Though it may be not an error but special behaviour of PCRE implementation in multiline environment. |
Ah, the second issue ( |
I have just applied your patch 👍 Thanks for your valuable collaboration :-) |
hilightLine now concatenates whole areas delimited by color stack
instead of every next character separately.
Nicola, I added a smaller improvement in
hilightLine
. Not that I really detected real speed improvement after it, but the change made concatenation algorithm cleaner by retirement of concatenation of every character by(++)
.