lkml.org 
[lkml]   [2004]   [Sep]   [23]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateWed, 22 Sep 2004 23:06:28 -0700
FromUlrich Drepper <>
Subject[PATCH] Simplify last lib/idr.c change
-----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@redhat.com>

- --- 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@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:06    [from the cache]
©2003-2008