[pacman-dev] [PATCH 1/2] only create string when needed

jjacky i.am.jack.mail at gmail.com
Mon Jan 9 15:37:31 EST 2012


 The entry's name is only used when not "." or ".." so
 only print the string then. (I'm guessing enormous
 speed improvements right there... :p)

Signed-off-by: Olivier Brunel <i.am.jack.mail at gmail.com>
---
 src/pacman/util.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pacman/util.c b/src/pacman/util.c
index 467bedf..2d88bac 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -191,9 +191,9 @@ int rmrf(const char *path)
 		}
 		for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
 			if(dp->d_ino) {
-				char name[PATH_MAX];
-				sprintf(name, "%s/%s", path, dp->d_name);
 				if(strcmp(dp->d_name, "..") != 0 && strcmp(dp->d_name, ".") != 0) {
+					char name[PATH_MAX];
+					snprintf(name, PATH_MAX, "%s/%s", path, dp->d_name);
 					errflag += rmrf(name);
 				}
 			}
-- 
1.7.8.3



More information about the pacman-dev mailing list