From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] no branch
Date: Mon, 25 Mar 2024 05:33:15 +0000 [thread overview]
Message-ID: <20240325053315.3393197-1-e@80x24.org> (raw)
---
object.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/object.c b/object.c
index 4219da9e3b..0224712a1c 100644
--- a/object.c
+++ b/object.c
@@ -74,12 +74,10 @@ static unsigned int hash_obj(const struct object_id *oid, unsigned int n)
static void insert_obj_hash(struct object *obj, struct object **hash, unsigned int size)
{
unsigned int j = hash_obj(&obj->oid, size);
+ unsigned int mask = size - 1;
- while (hash[j]) {
- j++;
- if (j >= size)
- j = 0;
- }
+ while (hash[j])
+ j = (j + 1) & mask;
hash[j] = obj;
}
@@ -89,19 +87,18 @@ static void insert_obj_hash(struct object *obj, struct object **hash, unsigned i
*/
struct object *lookup_object(struct repository *r, const struct object_id *oid)
{
- unsigned int i, first;
+ unsigned int i, first, mask;
struct object *obj;
if (!r->parsed_objects->obj_hash)
return NULL;
first = i = hash_obj(oid, r->parsed_objects->obj_hash_size);
+ mask = r->parsed_objects->obj_hash_size - 1;
while ((obj = r->parsed_objects->obj_hash[i]) != NULL) {
if (oideq(oid, &obj->oid))
break;
- i++;
- if (i == r->parsed_objects->obj_hash_size)
- i = 0;
+ i = (i + 1) & mask;
}
if (obj && i != first) {
/*
reply other threads:[~2024-03-25 5:33 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=20240325053315.3393197-1-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).