[WTF CVS] wtf/lib/WTF/Pages Admin.pm,1.6,1.7 Input.pm,1.8,1.9
Brought to you by:
gryphonshafer
From: Gryphon S. <gry...@us...> - 2006-12-06 16:09:39
|
Update of /cvsroot/wtf-tracker/wtf/lib/WTF/Pages In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv14298/lib/WTF/Pages Modified Files: Admin.pm Input.pm Log Message: After someone pointed out that index() is faster than substr(), time to refactor a few lines of code across the application. Index: Admin.pm =================================================================== RCS file: /cvsroot/wtf-tracker/wtf/lib/WTF/Pages/Admin.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Admin.pm 2 Dec 2006 00:09:09 -0000 1.6 --- Admin.pm 6 Dec 2006 16:09:34 -0000 1.7 *************** *** 419,428 **** my $update = sub { my ($name) = @_; - my $length = length($name) + 1; if ( $table->{ 'has_' . $name } ) { $dbh->do( 'UPDATE ' . $table->{'table'} . ' SET ' . $name . ' = 1 WHERE id IN ( ' . join( ', ', ! map { substr( $_, $length ) } grep { substr( $_, 0, $length ) eq $name . '_' } $req->param() ) . ')' ) or die $dbh->errstr(); } --- 419,429 ---- my $update = sub { my ($name) = @_; if ( $table->{ 'has_' . $name } ) { $dbh->do( 'UPDATE ' . $table->{'table'} . ' SET ' . $name . ' = 1 WHERE id IN ( ' . join( ', ', ! map { substr( $_, length($name) + 1 ) } ! grep { index( $_, $name . '_' ) == 0 } $req->param() ! ) . ')' ) or die $dbh->errstr(); } Index: Input.pm =================================================================== RCS file: /cvsroot/wtf-tracker/wtf/lib/WTF/Pages/Input.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Input.pm 3 Dec 2006 23:03:43 -0000 1.8 --- Input.pm 6 Dec 2006 16:09:34 -0000 1.9 *************** *** 221,225 **** grep { $_->[1] > 0 } map { [ substr( $_, 9 ), $req->param($_) || 0 ] } ! grep { substr( $_, 0, 9 ) eq 'activity_' } keys %{ $req->param() }; # if there is any activity data submitted from the tracker form, insert a --- 221,225 ---- grep { $_->[1] > 0 } map { [ substr( $_, 9 ), $req->param($_) || 0 ] } ! grep { index( $_, 'activity_' ) == 0 } keys %{ $req->param() }; # if there is any activity data submitted from the tracker form, insert a |