@matheusbsbs / matheus-bagliano / commits / ff7e6aad6d
Fork 0

Cleanup of unused symcache variable inside diff-lib.c

Commit c40641b77b0274186fd1b327d5dc3246f814aaaf, 'Optimize symlink/directory detection' by Linus Torvalds, removed the 'char *symcache' parameter to the has_symlink_leading_path() function. This made all variables currently named 'symcache' inside diff-lib.c unnecessary. This also let us throw away the 'struct oneway_unpack_data', and instead directly use the 'struct rev_info *revs' member, which was the only member left after removal of the 'symcache[] array' member. The 'struct oneway_unpack_data' was introduced by the following commit: 948dd346 "diff-files: careful when inspecting work tree items" Impact: cleanup PATH_MAX bytes less memory stack usage in some cases Signed-off-by: Kjetil Barvik <barvik@broadpark.no> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kjetil Barvik committed Jan 11, 2009 at 19:36 UTC ff7e6aad6d995a52e88cfeaae10cf8a768ff2358
1 file changed +11 -29
diff-lib.c
+11 -29
@@ -61,14 +61,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
61 int silent_on_removed = option & DIFF_SILENT_ON_REMOVED;
62 unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)
63 ? CE_MATCH_RACY_IS_DIRTY : 0);
64 - char symcache[PATH_MAX];
64
65 diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/");
66
67 if (diff_unmerged_stage < 0)
68 diff_unmerged_stage = 2;
69 entries = active_nr;
71 - symcache[0] = '\0';
70 for (i = 0; i < entries; i++) {
71 struct stat st;
72 unsigned int oldmode, newmode;
@@ -198,11 +196,6 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
196 * diff-index
197 */
198
201 -struct oneway_unpack_data {
202 - struct rev_info *revs;
203 - char symcache[PATH_MAX];
204 -};
205 -
199 /* A file entry went away or appeared */
200 static void diff_index_show_file(struct rev_info *revs,
201 const char *prefix,
@@ -216,8 +209,7 @@ static void diff_index_show_file(struct rev_info *revs,
209 static int get_stat_data(struct cache_entry *ce,
210 const unsigned char **sha1p,
211 unsigned int *modep,
219 - int cached, int match_missing,
220 - struct oneway_unpack_data *cbdata)
212 + int cached, int match_missing)
213 {
214 const unsigned char *sha1 = ce->sha1;
215 unsigned int mode = ce->ce_mode;
@@ -248,25 +240,24 @@ static int get_stat_data(struct cache_entry *ce,
240 return 0;
241 }
242
251 -static void show_new_file(struct oneway_unpack_data *cbdata,
243 +static void show_new_file(struct rev_info *revs,
244 struct cache_entry *new,
245 int cached, int match_missing)
246 {
247 const unsigned char *sha1;
248 unsigned int mode;
257 - struct rev_info *revs = cbdata->revs;
249
250 /*
251 * New file in the index: it might actually be different in
252 * the working copy.
253 */
263 - if (get_stat_data(new, &sha1, &mode, cached, match_missing, cbdata) < 0)
254 + if (get_stat_data(new, &sha1, &mode, cached, match_missing) < 0)
255 return;
256
257 diff_index_show_file(revs, "+", new, sha1, mode);
258 }
259
269 -static int show_modified(struct oneway_unpack_data *cbdata,
260 +static int show_modified(struct rev_info *revs,
261 struct cache_entry *old,
262 struct cache_entry *new,
263 int report_missing,
@@ -274,9 +265,8 @@ static int show_modified(struct oneway_unpack_data *cbdata,
265 {
266 unsigned int mode, oldmode;
267 const unsigned char *sha1;
277 - struct rev_info *revs = cbdata->revs;
268
279 - if (get_stat_data(new, &sha1, &mode, cached, match_missing, cbdata) < 0) {
269 + if (get_stat_data(new, &sha1, &mode, cached, match_missing) < 0) {
270 if (report_missing)
271 diff_index_show_file(revs, "-", old,
272 old->sha1, old->ce_mode);
@@ -344,8 +334,7 @@ static void do_oneway_diff(struct unpack_trees_options *o,
334 struct cache_entry *idx,
335 struct cache_entry *tree)
336 {
347 - struct oneway_unpack_data *cbdata = o->unpack_data;
348 - struct rev_info *revs = cbdata->revs;
337 + struct rev_info *revs = o->unpack_data;
338 int match_missing, cached;
339
340 /*
@@ -368,7 +357,7 @@ static void do_oneway_diff(struct unpack_trees_options *o,
357 * Something added to the tree?
358 */
359 if (!tree) {
371 - show_new_file(cbdata, idx, cached, match_missing);
360 + show_new_file(revs, idx, cached, match_missing);
361 return;
362 }
363
@@ -381,7 +370,7 @@ static void do_oneway_diff(struct unpack_trees_options *o,
370 }
371
372 /* Show difference between old and new */
384 - show_modified(cbdata, tree, idx, 1, cached, match_missing);
373 + show_modified(revs, tree, idx, 1, cached, match_missing);
374 }
375
376 static inline void skip_same_name(struct cache_entry *ce, struct unpack_trees_options *o)
@@ -418,8 +407,7 @@ static int oneway_diff(struct cache_entry **src, struct unpack_trees_options *o)
407 {
408 struct cache_entry *idx = src[0];
409 struct cache_entry *tree = src[1];
421 - struct oneway_unpack_data *cbdata = o->unpack_data;
422 - struct rev_info *revs = cbdata->revs;
410 + struct rev_info *revs = o->unpack_data;
411
412 if (idx && ce_stage(idx))
413 skip_same_name(idx, o);
@@ -446,7 +434,6 @@ int run_diff_index(struct rev_info *revs, int cached)
434 const char *tree_name;
435 struct unpack_trees_options opts;
436 struct tree_desc t;
449 - struct oneway_unpack_data unpack_cb;
437
438 mark_merge_entries();
439
@@ -456,14 +443,12 @@ int run_diff_index(struct rev_info *revs, int cached)
443 if (!tree)
444 return error("bad tree object %s", tree_name);
445
459 - unpack_cb.revs = revs;
460 - unpack_cb.symcache[0] = '\0';
446 memset(&opts, 0, sizeof(opts));
447 opts.head_idx = 1;
448 opts.index_only = cached;
449 opts.merge = 1;
450 opts.fn = oneway_diff;
466 - opts.unpack_data = &unpack_cb;
451 + opts.unpack_data = revs;
452 opts.src_index = &the_index;
453 opts.dst_index = NULL;
454
@@ -486,7 +471,6 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
471 struct cache_entry *last = NULL;
472 struct unpack_trees_options opts;
473 struct tree_desc t;
489 - struct oneway_unpack_data unpack_cb;
474
475 /*
476 * This is used by git-blame to run diff-cache internally;
@@ -515,14 +499,12 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
499 if (!tree)
500 die("bad tree object %s", sha1_to_hex(tree_sha1));
501
518 - unpack_cb.revs = &revs;
519 - unpack_cb.symcache[0] = '\0';
502 memset(&opts, 0, sizeof(opts));
503 opts.head_idx = 1;
504 opts.index_only = 1;
505 opts.merge = 1;
506 opts.fn = oneway_diff;
525 - opts.unpack_data = &unpack_cb;
507 + opts.unpack_data = &revs;
508 opts.src_index = &the_index;
509 opts.dst_index = &the_index;
510