##// END OF EJS Templates
xdiff: remove patience and histogram diff algorithms...
Jun Wu -
r36690:9e7b14ca default
parent child Browse files
Show More
@@ -27,6 +27,8 b''
27 extern "C" {
27 extern "C" {
28 #endif /* #ifdef __cplusplus */
28 #endif /* #ifdef __cplusplus */
29
29
30 #include <stddef.h> /* size_t */
31
30 /* xpparm_t.flags */
32 /* xpparm_t.flags */
31 #define XDF_NEED_MINIMAL (1 << 0)
33 #define XDF_NEED_MINIMAL (1 << 0)
32
34
@@ -41,11 +43,6 b' extern "C" {'
41
43
42 #define XDF_IGNORE_BLANK_LINES (1 << 7)
44 #define XDF_IGNORE_BLANK_LINES (1 << 7)
43
45
44 #define XDF_PATIENCE_DIFF (1 << 14)
45 #define XDF_HISTOGRAM_DIFF (1 << 15)
46 #define XDF_DIFF_ALGORITHM_MASK (XDF_PATIENCE_DIFF | XDF_HISTOGRAM_DIFF)
47 #define XDF_DIFF_ALG(x) ((x) & XDF_DIFF_ALGORITHM_MASK)
48
49 #define XDF_INDENT_HEURISTIC (1 << 23)
46 #define XDF_INDENT_HEURISTIC (1 << 23)
50
47
51 /* xdemitconf_t.flags */
48 /* xdemitconf_t.flags */
@@ -328,12 +328,6 b' int xdl_do_diff(mmfile_t *mf1, mmfile_t '
328 xdalgoenv_t xenv;
328 xdalgoenv_t xenv;
329 diffdata_t dd1, dd2;
329 diffdata_t dd1, dd2;
330
330
331 if (XDF_DIFF_ALG(xpp->flags) == XDF_PATIENCE_DIFF)
332 return xdl_do_patience_diff(mf1, mf2, xpp, xe);
333
334 if (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF)
335 return xdl_do_histogram_diff(mf1, mf2, xpp, xe);
336
337 if (xdl_prepare_env(mf1, mf2, xpp, xe) < 0) {
331 if (xdl_prepare_env(mf1, mf2, xpp, xe) < 0) {
338
332
339 return -1;
333 return -1;
@@ -27,7 +27,6 b''
27 #define XDL_MAX_EQLIMIT 1024
27 #define XDL_MAX_EQLIMIT 1024
28 #define XDL_SIMSCAN_WINDOW 100
28 #define XDL_SIMSCAN_WINDOW 100
29 #define XDL_GUESS_NLINES1 256
29 #define XDL_GUESS_NLINES1 256
30 #define XDL_GUESS_NLINES2 20
31
30
32
31
33 typedef struct s_xdlclass {
32 typedef struct s_xdlclass {
@@ -181,9 +180,7 b' static int xdl_prepare_ctx(unsigned int '
181 if (!(recs = (xrecord_t **) xdl_malloc(narec * sizeof(xrecord_t *))))
180 if (!(recs = (xrecord_t **) xdl_malloc(narec * sizeof(xrecord_t *))))
182 goto abort;
181 goto abort;
183
182
184 if (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF)
183 {
185 hbits = hsize = 0;
186 else {
187 hbits = xdl_hashbits((unsigned int) narec);
184 hbits = xdl_hashbits((unsigned int) narec);
188 hsize = 1 << hbits;
185 hsize = 1 << hbits;
189 if (!(rhash = (xrecord_t **) xdl_malloc(hsize * sizeof(xrecord_t *))))
186 if (!(rhash = (xrecord_t **) xdl_malloc(hsize * sizeof(xrecord_t *))))
@@ -209,8 +206,7 b' static int xdl_prepare_ctx(unsigned int '
209 crec->ha = hav;
206 crec->ha = hav;
210 recs[nrec++] = crec;
207 recs[nrec++] = crec;
211
208
212 if ((XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF) &&
209 if (xdl_classify_record(pass, cf, rhash, hbits, crec) < 0)
213 xdl_classify_record(pass, cf, rhash, hbits, crec) < 0)
214 goto abort;
210 goto abort;
215 }
211 }
216 }
212 }
@@ -266,21 +262,12 b' int xdl_prepare_env(mmfile_t *mf1, mmfil'
266
262
267 memset(&cf, 0, sizeof(cf));
263 memset(&cf, 0, sizeof(cf));
268
264
269 /*
265 sample = XDL_GUESS_NLINES1;
270 * For histogram diff, we can afford a smaller sample size and
271 * thus a poorer estimate of the number of lines, as the hash
272 * table (rhash) won't be filled up/grown. The number of lines
273 * (nrecs) will be updated correctly anyway by
274 * xdl_prepare_ctx().
275 */
276 sample = (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF
277 ? XDL_GUESS_NLINES2 : XDL_GUESS_NLINES1);
278
266
279 enl1 = xdl_guess_lines(mf1, sample) + 1;
267 enl1 = xdl_guess_lines(mf1, sample) + 1;
280 enl2 = xdl_guess_lines(mf2, sample) + 1;
268 enl2 = xdl_guess_lines(mf2, sample) + 1;
281
269
282 if (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF &&
270 if (xdl_init_classifier(&cf, enl1 + enl2 + 1, xpp->flags) < 0)
283 xdl_init_classifier(&cf, enl1 + enl2 + 1, xpp->flags) < 0)
284 return -1;
271 return -1;
285
272
286 if (xdl_prepare_ctx(1, mf1, enl1, xpp, &cf, &xe->xdf1) < 0) {
273 if (xdl_prepare_ctx(1, mf1, enl1, xpp, &cf, &xe->xdf1) < 0) {
@@ -295,18 +282,14 b' int xdl_prepare_env(mmfile_t *mf1, mmfil'
295 return -1;
282 return -1;
296 }
283 }
297
284
298 if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) &&
285 if (xdl_optimize_ctxs(&cf, &xe->xdf1, &xe->xdf2) < 0) {
299 (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF) &&
300 xdl_optimize_ctxs(&cf, &xe->xdf1, &xe->xdf2) < 0) {
301
302 xdl_free_ctx(&xe->xdf2);
286 xdl_free_ctx(&xe->xdf2);
303 xdl_free_ctx(&xe->xdf1);
287 xdl_free_ctx(&xe->xdf1);
304 xdl_free_classifier(&cf);
288 xdl_free_classifier(&cf);
305 return -1;
289 return -1;
306 }
290 }
307
291
308 if (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF)
292 xdl_free_classifier(&cf);
309 xdl_free_classifier(&cf);
310
293
311 return 0;
294 return 0;
312 }
295 }
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now