]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Simplify last lib/idr.c change
authorUlrich Drepper <drepper@redhat.com>
Tue, 19 Oct 2004 01:15:27 +0000 (18:15 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 19 Oct 2004 01:15:27 +0000 (18:15 -0700)
The last change to alloc_layer in lib/idr.c unnecessarily complicates
the code and depending on the definition of spin_unlock will cause worse
code to be generated than necessary.  The following patch should improve
the situation.

Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
lib/idr.c

index 972eefcce2b3a9b3ed825bb1b852a92fd3260f38..7d92cfc23ac266931b2450c79d818c7fb8691652 100644 (file)
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -39,13 +39,11 @@ static struct idr_layer *alloc_layer(struct idr *idp)
        struct idr_layer *p;
 
        spin_lock(&idp->lock);
-       if (!(p = idp->id_free)) {
-               spin_unlock(&idp->lock);
-               return NULL;
+       if ((p = idp->id_free)) {
+               idp->id_free = p->ary[0];
+               idp->id_free_cnt--;
+               p->ary[0] = NULL;
        }
-       idp->id_free = p->ary[0];
-       idp->id_free_cnt--;
-       p->ary[0] = NULL;
        spin_unlock(&idp->lock);
        return(p);
 }