[PATCH] Simplify last lib/idr.c change

From: Ulrich Drepper
Date: Thu Sep 23 2004 - 01:08:04 EST


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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@xxxxxxxxxx>

- --- lib/idr.c-old 2004-09-22 23:02:15.000000000 -0700
+++ lib/idr.c 2004-09-22 23:03:06.000000000 -0700
@@ -39,13 +39,11 @@ static struct idr_layer *alloc_layer(str
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);
}


- --
â Ulrich Drepper â Red Hat, Inc. â 444 Castro St â Mountain View, CA â
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFBUmfk2ijCOnn/RHQRAvJ4AKCpd1bkrRkcHaDm+mDyfh1tMpj9EgCgqu2N
voeHnNuVH5cpBCDtafFjZoc=
=XUFL
-----END PGP SIGNATURE-----
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/