Ignore:
Timestamp:
2012/06/21 15:02:41 (12 years ago)
Author:
pineray
Message:

#1859
foreach でキーしか使わない場合に array_keys で配列を作ってから渡す方法だと、
メモリを倍ほど消費することがわかったので、見苦しいけれど不要なバリューを生成する方向に.
F*in' PHP!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/SC_CartSession.php

    r21925 r21935  
    5151        } 
    5252        // 1世代古いコピー情報は、削除しておく 
    53         foreach (array_keys($_SESSION) as $k) { 
    54             if ($k != $this->key_tmp && preg_match('/^savecart_/', $k)) { 
    55                 unset($this->cartSession[$productTypeId][$k]); 
     53        foreach ($_SESSION as $key => $value) { 
     54            if ($key != $this->key_tmp && preg_match('/^savecart_/', $key)) { 
     55                unset($this->cartSession[$productTypeId][$key]); 
    5656            } 
    5757        } 
     
    9797    function getNextCartID($productTypeId) { 
    9898        $count = array(); 
    99         foreach (array_keys($this->cartSession[$productTypeId]) as $key) { 
     99        foreach ($this->cartSession[$productTypeId] as $key => $value) { 
    100100            $count[] = $this->cartSession[$productTypeId][$key]['cart_no']; 
    101101        } 
     
    144144        $max = 0; 
    145145        if (count($this->cartSession[$productTypeId]) > 0) { 
    146             foreach (array_keys($this->cartSession[$productTypeId]) as $key) { 
     146            foreach ($this->cartSession[$productTypeId] as $key => $value) { 
    147147                if (is_numeric($key)) { 
    148148                    if ($max < $key) { 
     
    320320 
    321321        // 必要な項目以外を削除。 
    322         foreach (array_keys($arrProductsClass) as $key) { 
     322        foreach ($arrProductsClass as $key => $value) { 
    323323            if (!isset($arrNecessaryItems[$key])) { 
    324324                unset($arrProductsClass[$key]); 
     
    379379        foreach ($cartKeys as $key) { 
    380380            $cartItems = $this->getCartList($key); 
    381             foreach (array_keys($cartItems) as $itemKey) { 
     381            foreach ($cartItems as $itemKey => $itemValue) { 
    382382                $cartItem =& $cartItems[$itemKey]; 
    383383                $results[$key][$i] =& $cartItem; 
Note: See TracChangeset for help on using the changeset viewer.