From cfc9ff35215081a33adde29872553513d08f58bb Mon Sep 17 00:00:00 2001 From: llornkcor Date: Wed, 10 Aug 2005 00:45:31 +0000 Subject: 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. --- (limited to 'scripts/optimize-connect') 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 @@ +#!/usr/bin/perl + +# Strips unnecessary whitespace from SIGNAL() and SLOT() macros, +# so that this doesn't have to be done at runtime. +# Believe it or not, this actually speeds things up. +# +# Limitation: only 1 set of (...) inside the macro, so it can't handle +# signals and slots that have function pointers as arguments. + +for $arg (@ARGV) { + if ( 0 ) { + # opts + } else { + push @files, $arg; + } +} + +sub canonWS { + my ($s) = @_; + $s =~ s/(.)\s+(\W)/$1$2/g; + $s =~ s/(\W)\s+(.)/$1$2/g; + return $s; +}; + +for $file (@files) { + open F, $file; + $c = join "",; + close F; + $c =~ s/\b((?:SIGNAL|SLOT)\s*\(\s*)((?:[^\n;()]+|\([^()]*\))*)\)/"$1".canonWS($2).")"/egs; + open F, ">t$$"; + print F $c; + close F; + system("diff -u $file t$$"); +} -- cgit v0.9.0.2