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 <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tay Ray Chuan committed Jul 7, 2011 at 12:23 UTC 452f4fa51e1fd1d0e3155fb4f4d8913298ac63a6
1 file changed +3 -7
xdiff/xprepare.c
+3 -7
@@ -64,8 +64,6 @@ static int xdl_optimize_ctxs(xdfile_t *xdf1, xdfile_t *xdf2);
64
65
66 static int xdl_init_classifier(xdlclassifier_t *cf, long size, long flags) {
67 - long i;
68 -
67 cf->flags = flags;
68
69 cf->hbits = xdl_hashbits((unsigned int) size);
@@ -80,8 +78,7 @@ static int xdl_init_classifier(xdlclassifier_t *cf, long size, long flags) {
78 xdl_cha_free(&cf->ncha);
79 return -1;
80 }
83 - for (i = 0; i < cf->hsize; i++)
84 - cf->rchash[i] = NULL;
81 + memset(cf->rchash, 0, cf->hsize * sizeof(xdlclass_t *));
82
83 cf->count = 0;
84
@@ -136,7 +133,7 @@ static int xdl_classify_record(xdlclassifier_t *cf, xrecord_t **rhash, unsigned
133 static int xdl_prepare_ctx(mmfile_t *mf, long narec, xpparam_t const *xpp,
134 xdlclassifier_t *cf, xdfile_t *xdf) {
135 unsigned int hbits;
139 - long i, nrec, hsize, bsize;
136 + long nrec, hsize, bsize;
137 unsigned long hav;
138 char const *blk, *cur, *top, *prev;
139 xrecord_t *crec;
@@ -164,8 +161,7 @@ static int xdl_prepare_ctx(mmfile_t *mf, long narec, xpparam_t const *xpp,
161 xdl_cha_free(&xdf->rcha);
162 return -1;
163 }
167 - for (i = 0; i < hsize; i++)
168 - rhash[i] = NULL;
164 + memset(rhash, 0, hsize * sizeof(xrecord_t *));
165
166 nrec = 0;
167 if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) {