| 1 |
Unpacking the manual twice, just to find out wherher it's utf8 -- Bad.
|
| 2 |
Launching awk per file instead of per dir -- Bad.
|
| 3 |
Determining which decompressor to use twice -- Bad.
|
| 4 |
Constantly sorting the database keeping it inconsistent -- Bad.
|
| 5 |
|
| 6 |
diff -up man-1.6f/src/makewhatis.sh.perf man-1.6f/src/makewhatis.sh
|
| 7 |
--- man-1.6f/src/makewhatis.sh.perf 2009-04-19 23:02:45.673198925 +0200
|
| 8 |
+++ man-1.6f/src/makewhatis.sh 2009-04-19 23:02:45.691198800 +0200
|
| 9 |
@@ -36,6 +36,8 @@
|
| 10 |
# 060719 - section choosing behavior to match man's (Mike frysinger).
|
| 11 |
#
|
| 12 |
# 090419 - Add -U flag, Lubomir Rintel <lkundrak@v3.sk>
|
| 13 |
+# 090419 - Don't write the database until we're finished, Lubomir Rintel <lkundrak@v3.sk>
|
| 14 |
+# 090419 - Substantial performance improvements, Lubomir Rintel <lkundrak@v3.sk>
|
| 15 |
#
|
| 16 |
# Note for Slackware users: "makewhatis -v -w -c" will work.
|
| 17 |
#
|
| 18 |
@@ -218,24 +220,7 @@ do
|
| 19 |
cd ${pages}$i
|
| 20 |
section=$i
|
| 21 |
curdir=$mandir/${pages}$i
|
| 22 |
- export section verbose curdir
|
| 23 |
-
|
| 24 |
- utf8=
|
| 25 |
- for x in $(find $mandir/${pages}$i -name '*' $findarg0 $findarg)
|
| 26 |
- do
|
| 27 |
- if [ "${x%.gz}" != "${x}" ]
|
| 28 |
- then
|
| 29 |
- cat=zcat
|
| 30 |
- elif [ "${x%.bz2}" != "${x}" ]
|
| 31 |
- then
|
| 32 |
- cat=bzcat
|
| 33 |
- else
|
| 34 |
- cat=cat
|
| 35 |
- fi
|
| 36 |
-
|
| 37 |
- if ${cat} ${x} | iconv -f utf-8 -t utf-8 -o /dev/null 2>/dev/null
|
| 38 |
- then
|
| 39 |
- echo ${x} | $AWK '
|
| 40 |
+ find $mandir/${pages}$i -name '*' $findarg0 $findarg | $AWK '
|
| 41 |
|
| 42 |
function readline() {
|
| 43 |
if (use_zcat || use_bzcat || use_lzcat) {
|
| 44 |
@@ -295,6 +280,8 @@ do
|
| 45 |
} else {
|
| 46 |
pipe_cmd = "lzcat \"" filename "\" 2>/dev/null";
|
| 47 |
}
|
| 48 |
+ # Chuck output unless it is utf-8
|
| 49 |
+ pipe_cmd = pipe_cmd " |iconv -f utf-8 -t utf-8 2>/dev/null"
|
| 50 |
# try to avoid suspicious stuff
|
| 51 |
if (filename ~ /[;&|`$(]/) {
|
| 52 |
print "ignored strange file name " filename " in " curdir > "/dev/stderr";
|
| 53 |
@@ -442,24 +429,23 @@ do
|
| 54 |
do_one();
|
| 55 |
}
|
| 56 |
' pages=$pages section=$section verbose=$verbose curdir=$curdir
|
| 57 |
- fi
|
| 58 |
- done
|
| 59 |
cd ..
|
| 60 |
fi
|
| 61 |
- done > $TMPFILE
|
| 62 |
+ done >> $TMPFILE
|
| 63 |
|
| 64 |
cd "$here"
|
| 65 |
|
| 66 |
- if [ -f ${whatisdb} ]
|
| 67 |
- then
|
| 68 |
- cat ${whatisdb} >> $TMPFILE
|
| 69 |
- fi
|
| 70 |
- tr -s '\n' < $TMPFILE | sort -u > ${whatisdb}
|
| 71 |
-
|
| 72 |
- chmod 644 ${whatisdb}
|
| 73 |
done
|
| 74 |
+
|
| 75 |
done
|
| 76 |
|
| 77 |
+if [ -f ${whatisdb} ]
|
| 78 |
+then
|
| 79 |
+ cat ${whatisdb} >> $TMPFILE
|
| 80 |
+fi
|
| 81 |
+tr -s '\n' < $TMPFILE | sort -u > ${whatisdb}
|
| 82 |
+chmod 644 ${whatisdb}
|
| 83 |
+
|
| 84 |
# remove tempdir
|
| 85 |
rm -rf $TMPFILE
|
| 86 |
|