# HG changeset patch # User Adam Chlipala # Date 1333916968 14400 # Node ID e263dab7b57928980fde8501c22610e2d7fe0077 # Parent c05e2e4bdde7059405eb410b932cccdbe144c3ac Optimize code from last changeset a bit diff -r c05e2e4bdde7 -r e263dab7b579 src/c/urweb.c --- a/src/c/urweb.c Sun Apr 08 16:24:16 2012 -0400 +++ b/src/c/urweb.c Sun Apr 08 16:29:28 2012 -0400 @@ -229,17 +229,18 @@ static client *find_client(unsigned id) { client *c; - - if (!pruning_thread_initialized || !pthread_equal(pruning_thread, pthread_self())) pthread_mutex_lock(&clients_mutex); + int i_am_pruner = pruning_thread_initialized && pthread_equal(pruning_thread, pthread_self()); + + 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; }