[uClibc-cvs] CVS update of uClibc/ldso/include (dl-string.h)

Joakim Tjernlund jocke at codepoet.org
Tue Aug 10 14:44:35 UTC 2004


    Date: Tuesday, August 10, 2004 @ 08:44:35
  Author: jocke
    Path: /var/cvs/uClibc/ldso/include

Modified: dl-string.h (1.6 -> 1.7)

_dl_get_last_path_component:
  handle "" strings and optimze it.

_dl_simple_ltoa,_dl_simple_ltoahex:
 Optimize for archs which can do pre increment/decrement and load/store
 in one instruction.


Index: uClibc/ldso/include/dl-string.h
diff -u uClibc/ldso/include/dl-string.h:1.6 uClibc/ldso/include/dl-string.h:1.7
--- uClibc/ldso/include/dl-string.h:1.6	Sat Jun 19 13:54:40 2004
+++ uClibc/ldso/include/dl-string.h	Tue Aug 10 08:44:34 2004
@@ -177,32 +177,20 @@
 
 static inline char *_dl_get_last_path_component(char *path)
 {
-	char *s;
-	register char *ptr = path;
-	register char *prev = 0;
-
-	while (*ptr)
-		ptr++;
-	s = ptr - 1;
+	register char *ptr = path-1;
+
+	while (*++ptr)
+		;/* empty */
 
 	/* strip trailing slashes */
-	while (s != path && *s == '/') {
-		*s-- = '\0';
+	while (ptr != path && *--ptr == '/') {
+		*ptr = '\0';
 	}
 
 	/* find last component */
-	ptr = path;
-	while (*ptr != '\0') {
-	    if (*ptr == '/')
-		prev = ptr;
-	    ptr++;
-	}
-	s = prev;
-
-	if (s == NULL || s[1] == '\0')
-		return path;
-	else
-		return s+1;
+	while (ptr != path && *--ptr != '/')
+		;/* empty */
+	return ptr == path ? ptr : ptr+1;
 }
 
 /* Early on, we can't call printf, so use this to print out
@@ -211,33 +199,33 @@
 static inline char *_dl_simple_ltoa(char * local, unsigned long i)
 {
 	/* 21 digits plus null terminator, good for 64-bit or smaller ints */
-	char *p = &local[21];
-	*p-- = '\0';
+	char *p = &local[22];
+	*--p = '\0';
 	do {
 	    char temp;
 	    do_rem(temp, i, 10);
-	    *p-- = '0' + temp;
+	    *--p = '0' + temp;
 	    i /= 10;
 	} while (i > 0);
-	return p + 1;
+	return p;
 }
 
 static inline char *_dl_simple_ltoahex(char * local, unsigned long i)
 {
 	/* 21 digits plus null terminator, good for 64-bit or smaller ints */
-	char *p = &local[21];
-	*p-- = '\0';
+	char *p = &local[22];
+	*--p = '\0';
 	do {
 		char temp = i & 0xf;
 		if (temp <= 0x09)
-		    *p-- = '0' + temp;
+		    *--p = '0' + temp;
 		else
-		    *p-- = 'a' - 0x0a + temp;
+		    *--p = 'a' - 0x0a + temp;
 		i >>= 4;
 	} while (i > 0);
-	*p-- = 'x';
-	*p-- = '0';
-	return p + 1;
+	*--p = 'x';
+	*--p = '0';
+	return p;
 }
 
 



More information about the uClibc-cvs mailing list