You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brian Havard <br...@kheldar.apana.org.au> on 2000/12/05 10:24:07 UTC

Faster buildexports

I've found the new buildexports.sh script to be annoyingly slow for me,
probably because my sh is inefficient (it fork()s all subprocesses and, as
I've described before, fork() is horribly inefficient on OS/2) so I've
recoded it using awk. This version is MUCH faster and more readable too
without all those egreps & seds.

I'll commit this shortly if there's no objections, and please don't laugh
if I've done something silly in the awk code, it's the most awk I've done
in around 10 years :)


Index: buildexports.awk
===================================================================
RCS file: buildexports.awk
diff -N buildexports.awk
--- /dev/null	Tue Dec  5 00:10:08 2000
+++ buildexports.awk	Tue Dec  5 00:10:08 2000
@@ -0,0 +1,8 @@
+{
+    if ($1 ~ /^APR_/)
+        print "#if", $1;
+    if ($1 ~ /^apr_/)
+        print "const void *ap_hack_" $1 " = (const void *)" $1 ";";
+    if ($1 ~ /^\/APR_/)
+        print "#endif /*", substr($1,2), "*/";
+}
Index: buildexports.sh
===================================================================
RCS file: /home/cvs/httpd-2.0/build/buildexports.sh,v
retrieving revision 1.6
diff -u -r1.6 buildexports.sh
--- buildexports.sh	2000/12/04 18:56:11	1.6
+++ buildexports.sh	2000/12/05 08:10:08
@@ -17,27 +17,7 @@
 cd ../../../
 echo ""
 
-while read LINE
-do
-    if [ "x`echo $LINE | egrep  '^[:space:]*APR_'`" != "x" ]; then
-        ifline=`echo "$LINE" |\
-            sed -e 's%^\(.*\)%\#if \1%'`
-        echo $ifline
-    fi
-    if [ "x`echo $LINE | egrep  '^[:space:]*apr_'`" != "x" ]; then
-#        newline=`echo "$LINE" |\
-#            sed -e 's%^\(.*\)%extern const void *\1\\(void\);%'`
-#        echo $newline
-        newline=`echo "$LINE" |\
-            sed -e 's%^\(.*\)%const void *ap_hack_\1 = \(const void
*\)\1\;%'`
-        echo $newline
-    fi
-    if [ "x`echo $LINE | egrep  '^[:space:]*\/APR_'`" != "x" ]; then
-        endline=`echo "$LINE" |\
-            sed -e 's%^\/\(.*\)%\#endif \/\*\1\*\/%'`
-        echo "$endline"
-    fi
-done
+awk -f build/buildexports.awk
 
 echo ""
 echo "void *ap_ugly_hack;"

-- 
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------


Re: Faster buildexports

Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Tue, 5 Dec 2000 06:25:47 -0800 (PST), rbb@covalent.net wrote:

>
>
>WHOO HOO!!!!  Thank you Brian!  I have also noticed how slow buildexports
>is, but I couldn't see how to improve upon it.

Wow, that's the first "WHOO HOO" I've ever got here :)
I guess I may as well go ahead & commit it.



>On Tue, 5 Dec 2000, Brian Havard wrote:
>
>> I've found the new buildexports.sh script to be annoyingly slow for me,
>> probably because my sh is inefficient (it fork()s all subprocesses and, as
>> I've described before, fork() is horribly inefficient on OS/2) so I've
>> recoded it using awk. This version is MUCH faster and more readable too
>> without all those egreps & seds.
>> 
>> I'll commit this shortly if there's no objections, and please don't laugh
>> if I've done something silly in the awk code, it's the most awk I've done
>> in around 10 years :)

-- 
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------


Re: Faster buildexports

Posted by rb...@covalent.net.

WHOO HOO!!!!  Thank you Brian!  I have also noticed how slow buildexports
is, but I couldn't see how to improve upon it.

Ryan

On Tue, 5 Dec 2000, Brian Havard wrote:

> I've found the new buildexports.sh script to be annoyingly slow for me,
> probably because my sh is inefficient (it fork()s all subprocesses and, as
> I've described before, fork() is horribly inefficient on OS/2) so I've
> recoded it using awk. This version is MUCH faster and more readable too
> without all those egreps & seds.
> 
> I'll commit this shortly if there's no objections, and please don't laugh
> if I've done something silly in the awk code, it's the most awk I've done
> in around 10 years :)
> 
> 
> Index: buildexports.awk
> ===================================================================
> RCS file: buildexports.awk
> diff -N buildexports.awk
> --- /dev/null	Tue Dec  5 00:10:08 2000
> +++ buildexports.awk	Tue Dec  5 00:10:08 2000
> @@ -0,0 +1,8 @@
> +{
> +    if ($1 ~ /^APR_/)
> +        print "#if", $1;
> +    if ($1 ~ /^apr_/)
> +        print "const void *ap_hack_" $1 " = (const void *)" $1 ";";
> +    if ($1 ~ /^\/APR_/)
> +        print "#endif /*", substr($1,2), "*/";
> +}
> Index: buildexports.sh
> ===================================================================
> RCS file: /home/cvs/httpd-2.0/build/buildexports.sh,v
> retrieving revision 1.6
> diff -u -r1.6 buildexports.sh
> --- buildexports.sh	2000/12/04 18:56:11	1.6
> +++ buildexports.sh	2000/12/05 08:10:08
> @@ -17,27 +17,7 @@
>  cd ../../../
>  echo ""
>  
> -while read LINE
> -do
> -    if [ "x`echo $LINE | egrep  '^[:space:]*APR_'`" != "x" ]; then
> -        ifline=`echo "$LINE" |\
> -            sed -e 's%^\(.*\)%\#if \1%'`
> -        echo $ifline
> -    fi
> -    if [ "x`echo $LINE | egrep  '^[:space:]*apr_'`" != "x" ]; then
> -#        newline=`echo "$LINE" |\
> -#            sed -e 's%^\(.*\)%extern const void *\1\\(void\);%'`
> -#        echo $newline
> -        newline=`echo "$LINE" |\
> -            sed -e 's%^\(.*\)%const void *ap_hack_\1 = \(const void
> *\)\1\;%'`
> -        echo $newline
> -    fi
> -    if [ "x`echo $LINE | egrep  '^[:space:]*\/APR_'`" != "x" ]; then
> -        endline=`echo "$LINE" |\
> -            sed -e 's%^\/\(.*\)%\#endif \/\*\1\*\/%'`
> -        echo "$endline"
> -    fi
> -done
> +awk -f build/buildexports.awk
>  
>  echo ""
>  echo "void *ap_ugly_hack;"
> 
> -- 
>  ______________________________________________________________________________
>  |  Brian Havard                 |  "He is not the messiah!                   |
>  |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
>  ------------------------------------------------------------------------------
> 
> 


_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------