join: improve performance when operating on whole lines
authorPádraig Brady <P@draigBrady.com>
Tue, 31 Aug 2010 07:38:34 +0000 (08:38 +0100)
committerPádraig Brady <P@draigBrady.com>
Wed, 1 Sep 2010 15:12:45 +0000 (16:12 +0100)
Following on from commit f86bb696, 01-02-2010,
"join: make -t '' operate on the whole line".
Bypassing the delimiter search in this case,
gives about an 8% performance boost.

* src/join (xfields): Don't bother looking for '\n'
in the data, which we know won't be present.

src/join.c

index fa18c9d..6eaad65 100644 (file)
@@ -249,13 +249,13 @@ xfields (struct line *line)
   if (ptr == lim)
     return;
 
-  if (0 <= tab)
+  if (0 <= tab && tab != '\n')
     {
       char *sep;
       for (; (sep = memchr (ptr, tab, lim - ptr)) != NULL; ptr = sep + 1)
         extract_field (line, ptr, sep - ptr);
     }
-  else
+  else if (tab < 0)
     {
       /* Skip leading blanks before the first field.  */
       while (isblank (to_uchar (*ptr)))