@matheusbsbs / matheus-bagliano / commits / 4d3f4b80e4
Fork 0

diff-lib.c: don't strdup twice

The static function read_directory in diff-lib.c is only ever called with struct path_list lists with .strdup_paths turned on, i.e. path_list_insert will strdup the paths for us (again). Let's take advantage of that and stop doing it twice. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Jul 7, 2007 at 20:19 UTC 4d3f4b80e49275c7eaf6ba0dbddd6180957926b9
1 file changed +1 -1
diff-lib.c
+1 -1
@@ -24,7 +24,7 @@ static int read_directory(const char *path, struct path_list *list)
24
25 while ((e = readdir(dir)))
26 if (strcmp(".", e->d_name) && strcmp("..", e->d_name))
27 - path_list_insert(xstrdup(e->d_name), list);
27 + path_list_insert(e->d_name, list);
28
29 closedir(dir);
30 return 0;