Re: [RFC][PATCH] grep: enable threading for context line printing
- From
Fredrik Kuivinen <frekui@gmail.com>
- Date
- Mar 14, 2010, 20:03 UTC
- Message-ID
- <4c8ef71003141303h474429aegc0a2eb2f97e7ff69@mail.gmail.com>
- In-Reply-To
- <4B9D2864.9090808@lsrfire.ath.cx>
On Sun, Mar 14, 2010 at 19:18, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:
Show 11 quoted lines
> This patch makes work_done() in builtin/grep.c print hunk marks between > files if threading is used, while show_line() in grep.c still does the > same in the other case. The latter is controlled by the struct grep_opt > member show_hunk_mark: 0 means show_line() prints no hunk marks between > files, 1 means it prints them before the next file with matches and 2 > means it prints them before matches from the current file. > > Having two places for this is a bit ugly but it enables parallel grep > for the common -ABC options. Locking should be fine in add_work(). > > Comments?
The implementation looks correct. As you say it is a bit ugly, but I think it is worth it anyway. (The solutions I managed to come up with when I wrote the original threaded grep patch were even uglier, that is why I simply disabled the threading in that case.)
Symbolic constants for the magic values 0, 1, and 2 would make the code more readable.
- Fredrik