summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2005-08-10 00:45:31 (UTC)
committer llornkcor <llornkcor>2005-08-10 00:45:31 (UTC)
commitcfc9ff35215081a33adde29872553513d08f58bb (patch) (unidiff)
treec18beeaf0370f6eb44061fdaebec9c22728b6c38
parent944dd27abc957b8010fa006d34115de16924b8f6 (diff)
downloadopie-cfc9ff35215081a33adde29872553513d08f58bb.zip
opie-cfc9ff35215081a33adde29872553513d08f58bb.tar.gz
opie-cfc9ff35215081a33adde29872553513d08f58bb.tar.bz2
adding optimize-conmect perl script, originally given to opie by trolltech (but since lost by opie, or not added to cvs). This removes any white spaces from the connect macro, to speed things up at runtime.
Diffstat (more/less context) (show whitespace changes)
-rwxr-xr-xscripts/optimize-connect34
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/optimize-connect b/scripts/optimize-connect
new file mode 100755
index 0000000..c81ecae
--- a/dev/null
+++ b/scripts/optimize-connect
@@ -0,0 +1,34 @@
1#!/usr/bin/perl
2
3# Strips unnecessary whitespace from SIGNAL() and SLOT() macros,
4# so that this doesn't have to be done at runtime.
5# Believe it or not, this actually speeds things up.
6#
7# Limitation: only 1 set of (...) inside the macro, so it can't handle
8# signals and slots that have function pointers as arguments.
9
10for $arg (@ARGV) {
11 if ( 0 ) {
12 # opts
13 } else {
14 push @files, $arg;
15 }
16}
17
18sub canonWS {
19 my ($s) = @_;
20 $s =~ s/(.)\s+(\W)/$1$2/g;
21 $s =~ s/(\W)\s+(.)/$1$2/g;
22 return $s;
23};
24
25for $file (@files) {
26 open F, $file;
27 $c = join "",<F>;
28 close F;
29 $c =~ s/\b((?:SIGNAL|SLOT)\s*\(\s*)((?:[^\n;()]+|\([^()]*\))*)\)/"$1".canonWS($2).")"/egs;
30 open F, ">t$$";
31 print F $c;
32 close F;
33 system("diff -u $file t$$");
34}