diff options
author | Patrick Reynolds <patrick.reynolds@github.com> | 2014-07-29 14:43:39 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-07-30 11:29:33 -0700 |
commit | d0da003d5b1e65f6e52920e42582f43b357782ee (patch) | |
tree | 8e2dc93a14690fa10a5424716f7ed1b0a07fb1d8 /copy.c | |
parent | 583b61c1af1bac12d6b48b2583ad508b5ab9964c (diff) | |
download | git-d0da003d5b1e65f6e52920e42582f43b357782ee.tar.gz |
use a hashmap to make remotes fasterpr/remotes-in-hashmap
Remotes are stored as an array, so looking one up or adding one without
duplication is an O(n) operation. Reading an entire config file full of
remotes is O(n^2) in the number of remotes. For a repository with tens of
thousands of remotes, the running time can hit multiple minutes.
Hash tables are way faster. So we add a hashmap from remote name to
struct remote and use it for all lookups. The time to add a new remote to
a repo that already has 50,000 remotes drops from ~2 minutes to < 1
second.
We retain the old array of remotes so iterators proceed in config-file
order.
Signed-off-by: Patrick Reynolds <patrick.reynolds@github.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'copy.c')
0 files changed, 0 insertions, 0 deletions