Skip to content

Commit

Permalink
xdiff/xprepare: use memset()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rctay authored and gitster committed Jul 7, 2011
1 parent f696543 commit 452f4fa
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions xdiff/xprepare.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ static int xdl_optimize_ctxs(xdfile_t *xdf1, xdfile_t *xdf2);


static int xdl_init_classifier(xdlclassifier_t *cf, long size, long flags) {
long i;

cf->flags = flags;

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

cf->count = 0;

Expand Down Expand Up @@ -136,7 +133,7 @@ static int xdl_classify_record(xdlclassifier_t *cf, xrecord_t **rhash, unsigned
static int xdl_prepare_ctx(mmfile_t *mf, long narec, xpparam_t const *xpp,
xdlclassifier_t *cf, xdfile_t *xdf) {
unsigned int hbits;
long i, nrec, hsize, bsize;
long nrec, hsize, bsize;
unsigned long hav;
char const *blk, *cur, *top, *prev;
xrecord_t *crec;
Expand Down Expand Up @@ -164,8 +161,7 @@ static int xdl_prepare_ctx(mmfile_t *mf, long narec, xpparam_t const *xpp,
xdl_cha_free(&xdf->rcha);
return -1;
}
for (i = 0; i < hsize; i++)
rhash[i] = NULL;
memset(rhash, 0, hsize * sizeof(xrecord_t *));

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

0 comments on commit 452f4fa

Please sign in to comment.