From 09451e5faf06384ddcc6137e6999025e087adf7f Mon Sep 17 00:00:00 2001 From: Geoff Greer Date: Sat, 9 Feb 2013 03:52:15 -0800 Subject: [PATCH] I'm tired of looking at all these one-line ifs --- src/main.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/main.c b/src/main.c index cccb2157a..cf18932b3 100644 --- a/src/main.c +++ b/src/main.c @@ -46,34 +46,27 @@ int main(int argc, char **argv) { log_debug("PCRE Version: %s", pcre_version()); workers_len = (int)sysconf(_SC_NPROCESSORS_ONLN); - if (opts.literal) { + if (opts.literal) workers_len--; - } - if (opts.workers) { + if (opts.workers) workers_len = opts.workers; - } - if (workers_len < 1) { + if (workers_len < 1) workers_len = 1; - } + log_debug("Using %i workers", workers_len); done_adding_files = FALSE; workers = ag_calloc(workers_len, sizeof(pthread_t)); - if (pthread_cond_init(&files_ready, NULL)) { + if (pthread_cond_init(&files_ready, NULL)) die("pthread_cond_init failed!"); - } - if (pthread_mutex_init(&print_mtx, NULL)) { + if (pthread_mutex_init(&print_mtx, NULL)) die("pthread_mutex_init failed!"); - } - if (pthread_mutex_init(&stats_mtx, NULL)) { + if (pthread_mutex_init(&stats_mtx, NULL)) die("pthread_mutex_init failed!"); - } - if (pthread_mutex_init(&work_queue_mtx, NULL)) { + if (pthread_mutex_init(&work_queue_mtx, NULL)) die("pthread_mutex_init failed!"); - } - if (opts.casing == CASE_SMART) { + if (opts.casing == CASE_SMART) opts.casing = is_lowercase(opts.query) ? CASE_INSENSITIVE : CASE_SENSITIVE; - } if (opts.literal) { if (opts.casing == CASE_INSENSITIVE) {