Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Change while loops with foreach for performance
  • Loading branch information
acidvertigo committed Jan 10, 2012
1 parent feb8fc4 commit a6b3cd9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions catalog/includes/classes/order_total.php
Expand Up @@ -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);

Expand All @@ -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'],
Expand All @@ -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);
Expand Down

0 comments on commit a6b3cd9

Please sign in to comment.