Revision
112641
Author
cal@macports.org
Date
2013-10-28 11:57:30 -0700 (Mon, 28 Oct 2013)

Log Message

darwintrace: avoid some calls to stdlib string functions to avoid call overhead

Modified Paths

Diff

Modified: trunk/base/src/darwintracelib1.0/darwintrace.c (112640 => 112641)


--- trunk/base/src/darwintracelib1.0/darwintrace.c	2013-10-28 18:29:43 UTC (rev 112640)
+++ trunk/base/src/darwintracelib1.0/darwintrace.c	2013-10-28 18:57:30 UTC (rev 112641)
@@ -851,10 +851,10 @@
 		} else if (*curpos == '\0') {
 			/* empty entry, ignore */
 			continue;
-		} else if (strcmp(curpos, ".") == 0) {
+		} else if (curpos[0] == '.' && curpos[1] == '\0') {
 			/* no-op directory, ignore */
 			continue;
-		} else if (strcmp(curpos, "..") == 0) {
+		} else if (curpos[0] == '.' && curpos[1] == '.' && curpos[2] == '\0') {
 			/* walk up one directory */
 			char *lastSep = strrchr(normalizedpath, '/');
 			if (lastSep == NULL) {
@@ -869,12 +869,12 @@
 			continue;
 		}
 		/* default case: standard path, copy */
-		strcat(normpos, "/");
-		normpos++;
-		strcat(normpos, curpos);
+		*normpos++ = '/';
+		strcpy(normpos, curpos);
 	}
 	if (*normalizedpath == '\0') {
-		strcat(normalizedpath, "/");
+		*normalizedpath++ = '/';
+		*normalizedpath++ = '\0';
 	}
 
 	/* Iterate over the sandbox bounds and try to find a directive matching this path */