<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
From: Ulrich Drepper &lt;drepper@redhat.com&gt;

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 &lt;drepper@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
---

 25-akpm/lib/idr.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff -puN lib/idr.c~simplify-last-lib-idrc-change lib/idr.c
--- 25/lib/idr.c~simplify-last-lib-idrc-change	2004-09-22 23:16:52.349429736 -0700
+++ 25-akpm/lib/idr.c	2004-09-22 23:16:52.352429280 -0700
@@ -39,13 +39,11 @@ static struct idr_layer *alloc_layer(str
 	struct idr_layer *p;
 
 	spin_lock(&amp;idp-&gt;lock);
-	if (!(p = idp-&gt;id_free)) {
-		spin_unlock(&amp;idp-&gt;lock);
-		return NULL;
+	if ((p = idp-&gt;id_free)) {
+		idp-&gt;id_free = p-&gt;ary[0];
+		idp-&gt;id_free_cnt--;
+		p-&gt;ary[0] = NULL;
 	}
-	idp-&gt;id_free = p-&gt;ary[0];
-	idp-&gt;id_free_cnt--;
-	p-&gt;ary[0] = NULL;
 	spin_unlock(&amp;idp-&gt;lock);
 	return(p);
 }
_
</pre></body></html>