Opened 9 years ago

Last modified 8 years ago

#1184 closed Bug/Fehler

for-Schleife optimieren in /includes/functions/sessions.php — at Version 1

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

Description (last modified by Torsten Riemer)

Siehe dazu bitte diesen Thread im Experten Forum: Session-Handling in 2.0.2.2

Suche in "/includes/functions/sessions.php":

    if ($session_data != '') {
      $variables = array();
      $a = preg_split( "/(\w+)\|/", $session_data, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
      for( $i = 0; $i < count( $a ); $i = $i+2 ) {
        $variables[$a[$i]] = unserialize( $a[$i+1] );
      }
      return($variables);
    }

Hier wird bei jedem Loop in der for-Schleife ein count() gemacht.
So wäre es besser und viel schneller:

      for( $i = 0, $ca = count($a); $i < $ca; $i = $i+2 ) {
        $variables[$a[$i]] = unserialize( $a[$i+1] );
      }

Gruß,
noRiddle

Change History (1)

comment:1 by Torsten Riemer, 9 years ago

Component: AdminShop
Description: modified (diff)
Milestone: modified-shop-2.0.2.3
Version: 2.0.2.2
Note: See TracTickets for help on using tickets.