Permalink
Browse files

Change while loops with foreach for performance

  • Loading branch information...
1 parent feb8fc4 commit a6b3cd9181b163fe6571309b721df52174364c08 @acidvertigo acidvertigo committed Jan 10, 2012
Showing with 5 additions and 7 deletions.
  1. +5 −7 catalog/includes/classes/order_total.php
@@ -20,8 +20,7 @@ function order_total() {
if (defined('MODULE_ORDER_TOTAL_INSTALLED') && tep_not_null(MODULE_ORDER_TOTAL_INSTALLED)) {
$this->modules = explode(';', MODULE_ORDER_TOTAL_INSTALLED);
- reset($this->modules);
- while (list(, $value) = each($this->modules)) {
+ foreach ($this->modules as $value) {
include(DIR_WS_LANGUAGES . $language . '/modules/order_total/' . $value);
include(DIR_WS_MODULES . 'order_total/' . $value);
@@ -34,14 +33,14 @@ function order_total() {
function process() {
$order_total_array = array();
if (is_array($this->modules)) {
- reset($this->modules);
- while (list(, $value) = each($this->modules)) {
+ foreach ($this->modules as $value) {
$class = substr($value, 0, strrpos($value, '.'));
if ($GLOBALS[$class]->enabled) {
$GLOBALS[$class]->output = array();
$GLOBALS[$class]->process();
- for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) {
+ $n=sizeof($GLOBALS[$class]->output);
+ for ($i=0; $i<$n; $i++) {
if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) {
$order_total_array[] = array('code' => $GLOBALS[$class]->code,
'title' => $GLOBALS[$class]->output[$i]['title'],
@@ -60,8 +59,7 @@ function process() {
function output() {
$output_string = '';
if (is_array($this->modules)) {
- reset($this->modules);
- while (list(, $value) = each($this->modules)) {
+ foreach ($this->modules as $value) {
$class = substr($value, 0, strrpos($value, '.'));
if ($GLOBALS[$class]->enabled) {
$size = sizeof($GLOBALS[$class]->output);

0 comments on commit a6b3cd9

Please sign in to comment.