Permalink
Browse files

Precount sizeof for performance

  • Loading branch information...
1 parent 7522252 commit 3f0eb751f8ab8602a63f151c9026d347c1d51f16 unknown committed Aug 14, 2011
Showing with 6 additions and 4 deletions.
  1. +6 −4 catalog/includes/classes/message_stack.php
View
10 catalog/includes/classes/message_stack.php
@@ -26,7 +26,8 @@ function messageStack() {
$this->messages = array();
if (tep_session_is_registered('messageToStack')) {
- for ($i=0, $n=sizeof($messageToStack); $i<$n; $i++) {
+ $n=sizeof($messageToStack);
+ for ($i=0; $i<$n; $i++) {
$this->add($messageToStack[$i]['class'], $messageToStack[$i]['text'], $messageToStack[$i]['type']);
}
tep_session_unregister('messageToStack');
@@ -65,7 +66,8 @@ function output($class) {
$this->table_data_parameters = 'class="messageBox"';
$output = array();
- for ($i=0, $n=sizeof($this->messages); $i<$n; $i++) {
+ $n=sizeof($this->messages);
+ for ($i=0; $i<$n; $i++) {
if ($this->messages[$i]['class'] == $class) {
$output[] = $this->messages[$i];
}
@@ -76,8 +78,8 @@ function output($class) {
function size($class) {
$count = 0;
-
- for ($i=0, $n=sizeof($this->messages); $i<$n; $i++) {
+ $n=sizeof($this->messages);
+ for ($i=0; $i<$n; $i++) {
if ($this->messages[$i]['class'] == $class) {
$count++;
}

0 comments on commit 3f0eb75

Please sign in to comment.