From: René Scharfe Date: Thu, 27 Oct 2011 15:27:04 GMT Subject: Re: [PATCH] git grep: be careful to use mutices only when they are initialized Message-ID: <4EA97848.9080008@lsrfire.ath.cx> In-Reply-To: <7vmxcn1pob.fsf@alter.siamese.dyndns.org> Am 26.10.2011 22:08, schrieb Junio C Hamano: > Junio C Hamano writes: > >> The remainder of this message are hints and random thoughts on potential >> follow-up patches that may want to build on top of this patch for further >> clean-ups (not specifically meant for Dscho but for other people on both >> mailing lists). >> ... >> - Could we lose "#ifndef NO_PTHREADS" inside grep_sha1(), grep_file(), >> and possibly cmd_grep() functions and let the compiler optimize things >> away under NO_PTHREADS compilation? > > I suspect that the result of the conversion would look a lot cleaner if > the code is first cleaned up to move global variable like skip_first_line > and the mutexes into the grep_opt structure. Without such clean-up, I do > not think a conversion like this does not add much value. Each thread get its own copy of the grep_opt struct, but the mutexes and also skip_first_line must not be duplicated. They could be moved into a new struct that is pointed to by grep_opt, but I'm not sure it's a win. René