public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ulrich Drepper <drepper@redhat.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>
Subject: [PATCH] Simplify last lib/idr.c change
Date: Wed, 22 Sep 2004 23:06:28 -0700	[thread overview]
Message-ID: <415267E4.4080302@redhat.com> (raw)

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

                 reply	other threads:[~2004-09-23  6:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=415267E4.4080302@redhat.com \
    --to=drepper@redhat.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox