Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5e58e3f
)
Optimized id_pair() so that clumps of IDs get handled more
author
Wayne Davison
<wayned@samba.org>
Tue, 24 Jan 2006 19:39:09 +0000
(19:39 +0000)
committer
Wayne Davison
<wayned@samba.org>
Tue, 24 Jan 2006 19:39:09 +0000
(19:39 +0000)
efficiently.
uidlist.c
patch
|
blob
|
blame
|
history
diff --git
a/uidlist.c
b/uidlist.c
index
b9ab1b6
..
c992f07
100644
(file)
--- a/
uidlist.c
+++ b/
uidlist.c
@@
-352,11
+352,20
@@
void recv_uid_list(int f)
struct id_pair *id_pair(uid_t uid, gid_t gid)
{
struct id_pair *id_pair(uid_t uid, gid_t gid)
{
- int i;
-
- for (i = 0; i < pair_cnt; i++) {
- if (uid == pair_list[i].uid && gid == pair_list[i].gid)
- return pair_list + i;
+ static int j = 0;
+
+ if (pair_cnt) {
+ int start = j;
+ fprintf(stderr, "start = %d\n", start);
+ /* We start our search where we left off because
+ * the IDs usually come in clumps. */
+ do {
+ fprintf(stderr, "checking %d\n", j);
+ if (uid == pair_list[j].uid && gid == pair_list[j].gid)
+ return pair_list + j;
+ if (++j == pair_cnt)
+ j = 0;
+ } while (j != start);
}
if (pair_cnt == pair_alloc) {
}
if (pair_cnt == pair_alloc) {
@@
-364,7
+373,10
@@
struct id_pair *id_pair(uid_t uid, gid_t gid)
pair_list = realloc_array(pair_list, struct id_pair,
pair_alloc);
}
pair_list = realloc_array(pair_list, struct id_pair,
pair_alloc);
}
- pair_list[pair_cnt].uid = uid;
- pair_list[pair_cnt].gid = gid;
- return pair_list + pair_cnt++;
+
+ j = pair_cnt++;
+ pair_list[j].uid = uid;
+ pair_list[j].gid = gid;
+
+ return pair_list + j;
}
}