Skip to content

Commit 452f4fa

Browse files
rctaygitster
authored andcommitted
xdiff/xprepare: use memset()
Use memset() instead of a for loop to initialize. This could give a performance advantage. Signed-off-by: Tay Ray Chuan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f696543 commit 452f4fa

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

xdiff/xprepare.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ static int xdl_optimize_ctxs(xdfile_t *xdf1, xdfile_t *xdf2);
6464

6565

6666
static int xdl_init_classifier(xdlclassifier_t *cf, long size, long flags) {
67-
long i;
68-
6967
cf->flags = flags;
7068

7169
cf->hbits = xdl_hashbits((unsigned int) size);
@@ -80,8 +78,7 @@ static int xdl_init_classifier(xdlclassifier_t *cf, long size, long flags) {
8078
xdl_cha_free(&cf->ncha);
8179
return -1;
8280
}
83-
for (i = 0; i < cf->hsize; i++)
84-
cf->rchash[i] = NULL;
81+
memset(cf->rchash, 0, cf->hsize * sizeof(xdlclass_t *));
8582

8683
cf->count = 0;
8784

@@ -136,7 +133,7 @@ static int xdl_classify_record(xdlclassifier_t *cf, xrecord_t **rhash, unsigned
136133
static int xdl_prepare_ctx(mmfile_t *mf, long narec, xpparam_t const *xpp,
137134
xdlclassifier_t *cf, xdfile_t *xdf) {
138135
unsigned int hbits;
139-
long i, nrec, hsize, bsize;
136+
long nrec, hsize, bsize;
140137
unsigned long hav;
141138
char const *blk, *cur, *top, *prev;
142139
xrecord_t *crec;
@@ -164,8 +161,7 @@ static int xdl_prepare_ctx(mmfile_t *mf, long narec, xpparam_t const *xpp,
164161
xdl_cha_free(&xdf->rcha);
165162
return -1;
166163
}
167-
for (i = 0; i < hsize; i++)
168-
rhash[i] = NULL;
164+
memset(rhash, 0, hsize * sizeof(xrecord_t *));
169165

170166
nrec = 0;
171167
if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) {

0 commit comments

Comments
 (0)