Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
these changes fix two problems.
$ cat <<END | stack exec cgrep -- -v foo
foo
bar
END
Using 'cgreprc' configuration file...
cgrep: Prelude.head: empty list
With my change, I get the expected result:
$cat <<END | stack exec cgrep -- -v foo
foo
bar
END
Using 'cgreprc' configuration file...
:2:bar
When run on a long file with many matching lines,
cgrep becomes very slow. For instance,
I used a list of english-words and searched for the word
"house" which matches many lines:
$ git clone https://github.com/dwyl/english-words
$ time stack exec cgrep -- house english-words/words.txt
Using 'cgreprc' configuration file...
english-words/words.txt:7345:4:alehouse
english-words/words.txt:7346:4:alehouses
english-words/words.txt:8584:5:almshouse
english-words/words.txt:8585:5:almshouses
(...)
english-words/words.txt:351557:5:workhouse
english-words/words.txt:351558:5:workhoused
english-words/words.txt:351559:5:workhouses
real 1m29.212s
user 0m26.680s
sys 0m10.784s
The problem is a memory leak in Output.getOffset2d caused by the sharing of the
list prc defined in this function.
Doing the same search with my change to Output.getOffset2d yields the following statistics:
real 0m3.212s
user 0m3.116s
sys 0m0.260s
Frederik