From 340febaf99f96c3c386392fa9957029b2f191b46 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 8 Apr 2012 16:29:28 -0400 Subject: Optimize code from last changeset a bit --- src/c/urweb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/c') diff --git a/src/c/urweb.c b/src/c/urweb.c index 9f318c95..54ca5927 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -229,17 +229,18 @@ static int pruning_thread_initialized = 0; static client *find_client(unsigned id) { client *c; + int i_am_pruner = pruning_thread_initialized && pthread_equal(pruning_thread, pthread_self()); - if (!pruning_thread_initialized || !pthread_equal(pruning_thread, pthread_self())) pthread_mutex_lock(&clients_mutex); + if (!i_am_pruner) pthread_mutex_lock(&clients_mutex); if (id >= n_clients) { - if (!pruning_thread_initialized || !pthread_equal(pruning_thread, pthread_self())) pthread_mutex_unlock(&clients_mutex); + if (!i_am_pruner) pthread_mutex_unlock(&clients_mutex); return NULL; } c = clients[id]; - if (!pruning_thread_initialized || !pthread_equal(pruning_thread, pthread_self())) pthread_mutex_unlock(&clients_mutex); + if (!i_am_pruner) pthread_mutex_unlock(&clients_mutex); return c; } -- cgit v1.2.3