Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Jun 2008 23:26:19 +0300
From:      Alex Kozlov <spam@rm-rf.kiev.ua>
To:        Kris Kennaway <kris@FreeBSD.org>, ports@FreeBSD.org, spam@rm-rf.kiev.ua
Subject:   Re: INDEX build optimizations - please review
Message-ID:  <20080610202619.GA94066@ravenloft.kiev.ua>

next in thread | raw e-mail | index | archive | help
On Tue, Jun 10, 2008 at 06:45:32PM +0200, Kris Kennaway wrote:
> Please review and test the following patches that optimize port INDEX 
> builds (and as a side-effect, other recursive tree traversals).  I am 
> particularly interested in a comparison between old and new indexes 
> built locally: the only diff should be in audio/festvox-hvs [1].
Work on RELENG_6 only after this patch (maybe good candidate for MFC):


Index: usr.bin/make/var.c
@@ -1232,6 +1232,41 @@
 }

 /**
+ * Remove adjacent duplicate words.
+ *
+ * Results:
+ * A string containing the resulting words.
+ */
+static char *  
+VarUniq(const char *str)
+{
+   ArgArray    aa;
+   Buffer      *buf;           /* Buffer for new string */
+   int     i, j;
+
+   buf = Buf_Init(0);
+   brk_string(&aa, str, FALSE);
+
+   if (aa.argc > 2) {
+       for (j = 1, i = 2; i < aa.argc; i++) {
+           if (strcmp(aa.argv[i], aa.argv[j]) != 0 && (++j != i))
+               aa.argv[j] = aa.argv[i];
+       }
+       aa.argc = j + 1;
+   }
+
+   for (i = 1; i < aa.argc; i++) {
+       Buf_AddBytes(buf, strlen(aa.argv[i]), (Byte *)aa.argv[i]);
+       if (i != aa.argc - 1)
+           Buf_AddByte(buf, ' ');
+   }
+   Buf_AddByte(buf, '\0');
+
+   ArgArray_Done(&aa);
+   return (Buf_Peel(buf));
+}
+
+/**
  * Pass through the tstr looking for 1) escaped delimiters,
  * '$'s and backslashes (place the escaped character in
  * uninterpreted) and 2) unescaped $'s that aren't before
@@ -1681,6 +1716,7 @@
  *     the invocation.
  * :U  Converts variable to upper-case.
  * :L  Converts variable to lower-case.
+ * :u  ("uniq") Remove adjacent duplicate words.
  *
  * XXXHB update this comment or remove it and point to the man page.
  */
@@ -1793,6 +1829,10 @@
                newStr = VarModify(value, VarRoot, NULL);
                vp->ptr++;
                break;
+           case 'u':
+               newStr = VarUniq(value);
+               vp->ptr++;
+               break;
            default:
                newStr = sysVvarsub(vp, startc, v, value);
                break;


--
Adios



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080610202619.GA94066>