Index: src/main/php/helpers/LoggerPatternConverter.php =================================================================== --- src/main/php/helpers/LoggerPatternConverter.php (revision 912120) +++ src/main/php/helpers/LoggerPatternConverter.php (working copy) @@ -19,22 +19,6 @@ */ /** - * Array for fast space padding - * Used by {@link LoggerPatternConverter::spacePad()}. - * - * @package log4php - * @subpackage helpers - */ -$GLOBALS['log4php.LoggerPatternConverter.spaces'] = array( - " ", // 1 space - " ", // 2 spaces - " ", // 4 spaces - " ", // 8 spaces - " ", // 16 spaces - " " ); // 32 spaces - - -/** * LoggerPatternConverter is an abstract class that provides the formatting * functionality that derived classes need. * @@ -89,9 +73,9 @@ public function format(&$sbuf, $e) { $s = $this->convert($e); - if($s == null or empty($s)) { + if(empty($s)) { if(0 < $this->min) { - $this->spacePad($sbuf, $this->min); + $sbuf .= str_repeat(' ', $this->min); } return; } @@ -101,38 +85,13 @@ if($len > $this->max) { $sbuf .= substr($s , 0, ($len - $this->max)); } else if($len < $this->min) { - if($this->leftAlign) { - $sbuf .= $s; - $this->spacePad($sbuf, ($this->min - $len)); + if($this->leftAlign) { + $sbuf .= str_pad($s, $this->min, ' ', STR_PAD_RIGHT); } else { - $this->spacePad($sbuf, ($this->min - $len)); - $sbuf .= $s; + $sbuf .= str_pad($s, $this->min, ' ', STR_PAD_LEFT); } } else { $sbuf .= $s; } - } - - /** - * Fast space padding method. - * - * @param string &$sbuf string buffer - * @param integer $length pad length - * - * @todo reimplement using PHP string functions - */ - public function spacePad(&$sbuf, $length) { - while($length >= 32) { - $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5]; - $length -= 32; - } - - for($i = 4; $i >= 0; $i--) { - if(($length & (1<<$i)) != 0) { - $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i]; - } - } - - // $sbuf = str_pad($sbuf, $length); } }