From: Jonathan Nieder <jrnieder@gmail.com>
To: David Barr <davidbarr@google.com>
Cc: Git List <git@vger.kernel.org>,
Thomas Rast <trast@student.ethz.ch>,
Dmitry Ivankov <divanorama@gmail.com>,
Sverre Rabbelier <srabbelier@gmail.com>
Subject: [PATCH 2/4] fast-import: allow atom_table to grow dynamically
Date: Wed, 11 Apr 2012 07:14:14 -0500 [thread overview]
Message-ID: <20120411121414.GD19568@burratino> (raw)
In-Reply-To: <20120411121259.GB19568@burratino>
From: David Barr <david.barr@cordelta.com>
Date: Thu, 31 Mar 2011 22:59:57 +1100
Use a struct hash_table to allow the table for atom strings to
grow. See the previous commit for explanations.
[jn: with init_hash call, even though it's technically not needed]
Signed-off-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
fast-import.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index a79a1260..67769573 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -299,9 +299,8 @@ static size_t total_allocd;
static struct mem_pool *mem_pool;
/* Atom management */
-static unsigned int atom_table_sz = 4451;
static unsigned int atom_cnt;
-static struct atom_str **atom_table;
+static struct hash_table atom_table;
/* The .pack file being generated */
static unsigned int pack_id;
@@ -691,10 +690,11 @@ static struct object_entry *find_mark(uintmax_t idnum)
static struct atom_str *to_atom(const char *s, unsigned short len)
{
- unsigned int hc = hc_str(s, len) % atom_table_sz;
+ unsigned int hc = hc_str(s, len);
struct atom_str *c;
+ void **pos;
- for (c = atom_table[hc]; c; c = c->next_atom)
+ for (c = lookup_hash(hc, &atom_table); c; c = c->next_atom)
if (c->str_len == len && !strncmp(s, c->str_dat, len))
return c;
@@ -702,8 +702,12 @@ static struct atom_str *to_atom(const char *s, unsigned short len)
c->str_len = len;
strncpy(c->str_dat, s, len);
c->str_dat[len] = 0;
- c->next_atom = atom_table[hc];
- atom_table[hc] = c;
+ c->next_atom = NULL;
+ pos = insert_hash(hc, c, &atom_table);
+ if (pos) {
+ c->next_atom = *pos;
+ *pos = c;
+ }
atom_cnt++;
return c;
}
@@ -3270,7 +3274,7 @@ int main(int argc, const char **argv)
alloc_objects(object_entry_alloc);
strbuf_init(&command_buf, 0);
- atom_table = xcalloc(atom_table_sz, sizeof(struct atom_str*));
+ init_hash(&atom_table);
branch_table = xcalloc(branch_table_sz, sizeof(struct branch*));
avail_tree_table = xcalloc(avail_tree_table_sz, sizeof(struct avail_tree_content*));
init_hash(&object_table);
--
1.7.10
next prev parent reply other threads:[~2012-04-11 12:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-31 11:59 fast-import: use struct hash_table David Barr
2011-03-31 11:59 ` [PATCH 1/2] fast-import: use struct hash_table for atom strings David Barr
2011-04-02 2:42 ` Jonathan Nieder
2011-04-02 3:33 ` Jonathan Nieder
2011-03-31 11:59 ` [PATCH 2/2] fast-import: use struct hash_table for objects David Barr
2011-04-02 2:46 ` Jonathan Nieder
2011-04-02 2:48 ` fast-import: use struct hash_table Jonathan Nieder
2012-04-11 12:11 ` [PATCH/RFC v2 0/4] " Jonathan Nieder
2012-04-11 12:12 ` [PATCH/RFC v2 0/4 resend] " Jonathan Nieder
2012-04-11 12:13 ` [PATCH 1/4] fast-import: allow object_table to grow dynamically Jonathan Nieder
2012-04-11 12:14 ` Jonathan Nieder [this message]
2012-04-11 12:15 ` [PATCH 3/4] fast-import: allow branch_table " Jonathan Nieder
2012-04-11 12:15 ` [PATCH 4/4] fast-import: use DIV_ROUND_UP Jonathan Nieder
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120411121414.GD19568@burratino \
--to=jrnieder@gmail.com \
--cc=davidbarr@google.com \
--cc=divanorama@gmail.com \
--cc=git@vger.kernel.org \
--cc=srabbelier@gmail.com \
--cc=trast@student.ethz.ch \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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).