r49312 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49311‎ | r49312 | r49313 >
Date:13:05, 8 April 2009
Author:werdna
Status:deferred (Comments)
Tags:
Comment:
Replace existing ccnorm one with one that makes use of faststringsearch where available. In local benchmarking on 400kB pages, the existing function was aborted at 10 minutes, whereas the new function took just 47ms. So the new function is faster by at least 5 orders of magnitude
Modified paths:
  • /branches/preferences-work/extensions/AbuseFilter/AbuseFilter.parser.php (modified) (history)

Diff [purge]

Index: branches/preferences-work/extensions/AbuseFilter/AbuseFilter.parser.php
@@ -1089,16 +1089,20 @@
10901090 }
10911091
10921092 protected function ccnorm( $s ) {
1093 - if (!class_exists( 'AntiSpoof' ) ) {
1094 - return $s;
 1093+ static $equivset = null;
 1094+
 1095+ if ( is_null( $equivset ) ) {
 1096+ global $IP;
 1097+ require( "$IP/extensions/AntiSpoof/equivset.php" );
10951098 }
10961099
1097 - // Normalise confusable characters.
1098 - $chars = AntiSpoof::stringToList( $s );
1099 - $chars = AntiSpoof::equivString( $chars );
1100 - $s = AntiSpoof::listToString( $chars );
1101 -
1102 - return $s;
 1100+ if (function_exists('fss_prep_replace')) {
 1101+ $fss = fss_prep_replace( $equivset );
 1102+
 1103+ return fss_exec_replace( $fss, $s );
 1104+ } else {
 1105+ return strtr( $s, $equivset );
 1106+ }
11031107 }
11041108
11051109 protected function rmspecials( $s ) {
@@ -1201,4 +1205,4 @@
12021206 return preg_match("#^".strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.'))."$#i", $string);
12031207 } // end
12041208
1205 -} // end if
\ No newline at end of file
 1209+} // end if

Follow-up revisions

RevisionCommit summaryAuthorDate
r49751Merge in r49312 from preferences-work -- non preference related performance i...werdna03:37, 23 April 2009

Comments

#Comment by Werdna (talk | contribs)   13:06, 8 April 2009

Yeah, yeah. Wrong branch. I'll fix it later.

Status & tagging log