Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

speed improvement in smilie_replace. It is now almost as fast (within…

… 5-10%) of

the version that used global smilie definitions.
  • Loading branch information...
commit 690819315138830384b4eb45dd77e65a3866cb1a 1 parent 617778f
gregb_cc authored

Showing 1 changed file with 5 additions and 3 deletions. Show diff stats Hide diff stats

  1. +5 3 lib/weblib.php
8 lib/weblib.php
@@ -474,7 +474,8 @@ function replace_smilies($text) {
474 474 global $CFG;
475 475
476 476 static $runonce = false;
477   - static $smilies = false;
  477 + static $e = array();
  478 + static $img = array();
478 479 static $emoticons = array(
479 480 ':-)' => 'smiley.gif',
480 481 ':)' => 'smiley.gif',
@@ -502,12 +503,13 @@ function replace_smilies($text) {
502 503
503 504 if($runonce == false):
504 505 foreach ($emoticons as $emoticon => $image){
505   - $smilies[$emoticon] = "<IMG ALT=\"$emoticon\" WIDTH=15 HEIGHT=15 SRC=\"{$CFG->wwwroot}/pix/s/{$image}\">";
  506 + $e[] = $emoticon;
  507 + $img[] = "<IMG ALT=\"$emoticon\" WIDTH=15 HEIGHT=15 SRC=\"{$CFG->wwwroot}/pix/s/{$image}\">";
506 508 }
507 509 $runonce = true;
508 510 endif;
509 511
510   - return strtr($text, $smilies);
  512 + return str_replace($e, $img, $text);
511 513 }
512 514
513 515 function text_to_html($text, $smiley=true, $para=true) {

0 comments on commit 6908193

Please sign in to comment.
Something went wrong with that request. Please try again.