[patch] Vastly improved sources() function
Simon Brenner
simon.brenner at home.se
Mon May 12 16:39:08 GMT 2003
I found that AUTOPRUNE took a *very* long time to complete on my
computer (P2 450), something like hours... (I rarely let it complete the
AUTOPRUNE)
So I looked into the workings of the prune command, and found that the
subroutine taking up the most time was the sources() function in
sources.lunar.
I took the sources() function, and asked myself what could be taking it
so much time. Not very hard to find out, the problem was the two uses of
sed to replace references to $SOURCE0 into $SOURCE (The first source in
the DETAILS file is not indexed). Two calls to `sed s/SOURCE0/SOURCE/`
per source variable processed.
So, to eliminate the sed calls, I removed the sed calls and added one
line before the source variables are looped through:
SOURCE0=$SOURCE
, thereby eliminating the need to translate $SOURCE0 into $SOURCE
I tested it (no fancy timing or anything, just thumbs measure), and
found it roughly 10 times faster (serious!). A lunar prune completed in
a couple of minutes, instead of an hour
Well... Just apply the patch =) Not that I am a master at the inner
workings of lunar, but I can see no bugs caused by this modification...
I hope I made the world a slightly better place now =)
// Simon Brenner
-------------- next part --------------
*** sources.lunar Wed Apr 16 21:47:09 2003
--- /home/salparot/sources.lunar Mon May 12 16:18:33 2003
***************
*** 26,34 ****
run_details $1 || return 1
if [ -z "$CVS_MODULE" ]; then
for (( CNT=0; CNT<=$MAX_SOURCES; CNT++ )) ; do
! TEMP1=`echo SOURCE$CNT | sed s/SOURCE0/SOURCE/`
TEMP2=`echo SOURCE$(( CNT+1))`
TEMP3=`echo SOURCE$(( CNT+2))`
--- 26,36 ----
run_details $1 || return 1
+ SOURCE0=$SOURCE
+
if [ -z "$CVS_MODULE" ]; then
for (( CNT=0; CNT<=$MAX_SOURCES; CNT++ )) ; do
! TEMP1=`echo SOURCE$CNT`
TEMP2=`echo SOURCE$(( CNT+1))`
TEMP3=`echo SOURCE$(( CNT+2))`
***************
*** 50,56 ****
#lets clear the array
for (( CNT1=0; CNT1<=$CNT; CNT1++ ))
do
! TEMP1=`echo SOURCE$CNT1 | sed s/SOURCE0/SOURCE/`
unset $TEMP1
done
break
--- 52,58 ----
#lets clear the array
for (( CNT1=0; CNT1<=$CNT; CNT1++ ))
do
! TEMP1=`echo SOURCE$CNT1`
unset $TEMP1
done
break
More information about the Lunar
mailing list