svn commit: trunk/busybox/coreutils

vda at busybox.net vda at busybox.net
Sun Nov 26 15:48:54 UTC 2006


Author: vda
Date: 2006-11-26 07:48:54 -0800 (Sun, 26 Nov 2006)
New Revision: 16675

Log:
sort: two small optimizations


Modified:
   trunk/busybox/coreutils/sort.c


Changeset:
Modified: trunk/busybox/coreutils/sort.c
===================================================================
--- trunk/busybox/coreutils/sort.c	2006-11-26 15:48:03 UTC (rev 16674)
+++ trunk/busybox/coreutils/sort.c	2006-11-26 15:48:54 UTC (rev 16675)
@@ -70,8 +70,7 @@
 			for (i = 1; i < key->range[2*j] + j; i++) {
 				/* Skip leading blanks or first separator */
 				if (str[end]) {
-					if (!key_separator && isspace(str[end]))
-/* TODO: remove "&& isspace(str[end])" */
+					if (!key_separator)
 						while (isspace(str[end])) end++;
 				}
 				/* Skip body of key */
@@ -158,7 +157,7 @@
 	struct sort_key *key;
 
 	for (key = key_list; !retval && key; key = key->next_key) {
-		flags = (key->flags) ? key->flags : global_flags;
+		flags = key->flags ? key->flags : global_flags;
 		/* Chop out and modify key chunks, handling -dfib */
 		x = get_key(*(char **)xarg, key, flags);
 		y = get_key(*(char **)yarg, key, flags);
@@ -181,7 +180,8 @@
 #if ENABLE_FEATURE_SORT_BIG
 		case FLAG_g: {
 			char *xx, *yy;
-			double dx = strtod(x, &xx), dy = strtod(y, &yy);
+			double dx = strtod(x, &xx);
+			double dy = strtod(y, &yy);
 			/* not numbers < NaN < -infinity < numbers < +infinity) */
 			if (x == xx)
 				retval = (y == yy ? 0 : -1);
@@ -217,26 +217,27 @@
 			else if (!yy)
 				retval = 1;
 			else
-				retval = (dx==thyme.tm_mon) ? 0 : dx-thyme.tm_mon;
+				retval = (dx == thyme.tm_mon) ? 0 : dx - thyme.tm_mon;
 			break;
 		}
 		/* Full floating point version of -n */
 		case FLAG_n: {
-			double dx = atof(x), dy  =atof(y);
+			double dx = atof(x);
+			double dy = atof(y);
 			retval = (dx > dy) ? 1 : ((dx < dy) ? -1 : 0);
 			break;
 		}
-		}
+		} /* switch */
 		/* Free key copies. */
 		if (x != *(char **)xarg) free(x);
 		if (y != *(char **)yarg) free(y);
-		if (retval) break;
+		/* if (retval) break; - done by for() anyway */
 #else
 		/* Integer version of -n for tiny systems */
 		case FLAG_n:
 			retval = atoi(x) - atoi(y);
 			break;
-		}
+		} /* switch */
 #endif
 	}
 	/* Perform fallback sort if necessary */




More information about the busybox-cvs mailing list