Dirty hack for time-consuming str_replace
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Mon, 16 Aug 2004 21:39:56 +0000 (21:39 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Mon, 16 Aug 2004 21:39:56 +0000 (21:39 +0000)
includes/OutputPage.php

index 36c522c..a958397 100644 (file)
@@ -893,7 +893,28 @@ class OutputPage {
                        wfProfileOut( "$fname-construct" );
                        # Do the thing
                        wfProfileIn( "$fname-replace" );
-                       $this->mBodytext = str_replace( $search, $replace, $this->mBodytext );
+                       
+                       # Dirrrty hack
+                       $arr = explode ( "<!--LINK" , $this->mBodytext ) ;
+                       $tarr = array() ;
+                       foreach ( $arr AS $k => $v )
+                               {
+                               $t = explode ( "-->" , $v , 2 ) ;
+                               $tarr[$k] = $t[0]  ;
+                               }
+                       while ( count ( $search ) > 0 )
+                               {
+                               $s = array_pop ( $search ) ;
+                               $r = array_pop ( $replace ) ;
+                               $s = substr ( $s , 8 , strlen ( $s ) - 11 ) ;
+                               $k = array_search ( $s , $tarr ) ;
+                               if ( $k === false ) continue ;
+                               $arr[$k] = substr_replace ( $arr[$k] , $r , 0 , strlen ( $s ) + 3 ) ;
+                               unset ( $tarr[$k] ) ;
+                               }
+                       $this->mBodytext = implode ( "" , $arr ) ;
+                       
+#                      $this->mBodytext = str_replace( $search, $replace, $this->mBodytext );
                        wfProfileOut( "$fname-replace" );
                }
                wfProfileOut( $fname );