Modify

Opened 8 years ago

Closed 8 years ago

#1306 closed Frage (fixed)

orders_info_blocks.php : Optimieren zweier Schleifen

Reported by: anonymous Owned by: somebody
Priority: normal Milestone: modified-shop-2.0.4.0
Component: Admin Version: 2.0.3.0
Keywords: Cc:
Blocked By: Blocking:

Description

In der Datei ./admin/includes/modules/orders_info_blocks.php

gibt es zwei Stellen mit einer for-Schleife:

Zeile 181ff

if (isset($order->products[$i]!['attributes']) && sizeof($order->products[$i]!['attributes']) > 0) {
  for ($j = 0, $k = sizeof($order->products[$i]!['attributes']); $j < $k; $j ++) {
    echo '<br /><nobr><i>&nbsp; - '.$order->products[$i]!['attributes'][$j]!['option'].': '.$order->products[$i]!['attributes'][$j]!['value'].'</i></nobr> ';
  }
}

und Zeile 191ff

if (isset($order->products[$i]!['attributes']) && sizeof($order->products[$i]!['attributes']) > 0) {
  for ($j = 0, $k = sizeof($order->products[$i]!['attributes']); $j < $k; $j ++) {
    $model = $order->products[$i]!['attributes'][$j]!['attributes_model'];
    if ($model == !'') {
      $model = xtc_get_attributes_model($order->products[$i]!['id'], $order->products[$i]!['attributes'][$j]!['value'],$order->products[$i]!['attributes'][$j]!['option'], $lang);
    }
    echo (!empty($model) ? $attr_model_delimiter . $model : '<br />');
  }
}

wäre es nicht besser , diese Stellen wie folgt umzuschreiben:

Zeile 181ff

if ( isset($order->products[$i]!['attributes']) ) {
    $k = sizeof($order->products[$i]!['attributes']);
    if ( $k > 0 ) {
        for ($j = 0; $j < $k; $j ++) {
            echo '<br /><nobr><i>&nbsp; - '.$order->products[$i]!['attributes'][$j]!['option'].': '.$order->products[$i]!['attributes'][$j]!['value'].'</i></nobr> ';
        }
    }
}

und Zeile 191ff

if ( isset($order->products[$i]!['attributes']) ) {    
    /*$k = sizeof($order->products[$i]!['attributes']);*/
    if ( $k > 0) {
        for ($j = 0; $j < $k; $j++) {
            $model = $order->products[$i]!['attributes'][$j]!['attributes_model'];
            if ($model == !'') {
                $model = xtc_get_attributes_model($order->products[$i]!['id'], $order->products[$i]!['attributes'][$j]!['value'],$order->products[$i]!['attributes'][$j]!['option'], $lang);
            }
            echo (!empty($model) ? $attr_model_delimiter . $model : '<br />');
        }
    }
}

Damit müsste die Größe des Arrays mit den Attributen nur einmal bestimmt werden, und nicht bei jeder Schleife bei jedem Durchgang.
Ich habe die zweite Zeile mit der Größenbestimmung erst einmal auskommentiert, eventuell kann man auf diese verzichten.

Grüße
Rene

Attachments (0)

Change History (2)

comment:1 by Ronald Parcinski, 8 years ago

Kann man durchaus optimieren

comment:2 by Ronald Parcinski, 8 years ago

Resolution: fixed
Status: newclosed

In 11049:

fix #1306

Modify Ticket

Action
as closed The owner will remain somebody.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.