Make WordPress Core

Changeset 11599


Ignore:
Timestamp:
06/18/2009 07:38:08 PM (17 years ago)
Author:
ryan
Message:

Reduce SimplePie memory usage. Props link92. fixes #10147 for trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-simplepie.php

    r10747 r11599  
    752752        function __destruct()
    753753        {
    754                 if (!empty($this->data['items']))
    755                 {
    756                         foreach ($this->data['items'] as $item)
    757                         {
    758                                 $item->__destruct();
    759                         }
    760                         unset($this->data['items']);
    761                 }
    762                 if (!empty($this->data['ordered_items']))
    763                 {
    764                         foreach ($this->data['ordered_items'] as $item)
    765                         {
    766                                 $item->__destruct();
    767                         }
    768                         unset($this->data['ordered_items']);
     754                if (version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled())
     755                {
     756                        if (!empty($this->data['items']))
     757                        {
     758                                foreach ($this->data['items'] as $item)
     759                                {
     760                                        $item->__destruct();
     761                                }
     762                                unset($item, $this->data['items']);
     763                        }
     764                        if (!empty($this->data['ordered_items']))
     765                        {
     766                                foreach ($this->data['ordered_items'] as $item)
     767                                {
     768                                        $item->__destruct();
     769                                }
     770                                unset($item, $this->data['ordered_items']);
     771                        }
    769772                }
    770773        }
     
    30833086        function __destruct()
    30843087        {
    3085                 unset($this->feed);
     3088                if (version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled())
     3089                {
     3090                        unset($this->feed);
     3091                }
    30863092        }
    30873093
     
    56835689        }
    56845690
    5685         /**
    5686          * Remove items that link back to this before destroying this object
    5687          */
    5688         function __destruct()
    5689         {
    5690                 unset($this->item);
    5691         }
    5692 
    56935691        function get_source_tags($namespace, $tag)
    56945692        {
     
    89558953        function parse_url($url)
    89568954        {
    8957                 static $cache = array();
    8958                 if (isset($cache[$url]))
    8959                 {
    8960                         return $cache[$url];
    8961                 }
    8962                 elseif (preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $url, $match))
    8963                 {
    8964                         for ($i = count($match); $i <= 9; $i++)
    8965                         {
    8966                                 $match[$i] = '';
    8967                         }
    8968                         return $cache[$url] = array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]);
    8969                 }
    8970                 else
    8971                 {
    8972                         return $cache[$url] = array('scheme' => '', 'authority' => '', 'path' => '', 'query' => '', 'fragment' => '');
    8973                 }
     8955                preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $url, $match);
     8956                for ($i = count($match); $i <= 9; $i++)
     8957                {
     8958                        $match[$i] = '';
     8959                }
     8960                return array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]);
    89748961        }
    89758962
     
    1081010797        function codepoint_to_utf8($codepoint)
    1081110798        {
    10812                 static $cache = array();
    1081310799                $codepoint = (int) $codepoint;
    10814                 if (isset($cache[$codepoint]))
    10815                 {
    10816                         return $cache[$codepoint];
    10817                 }
    10818                 elseif ($codepoint < 0)
    10819                 {
    10820                         return $cache[$codepoint] = false;
     10800                if ($codepoint < 0)
     10801                {
     10802                        return false;
    1082110803                }
    1082210804                else if ($codepoint <= 0x7f)
    1082310805                {
    10824                         return $cache[$codepoint] = chr($codepoint);
     10806                        return chr($codepoint);
    1082510807                }
    1082610808                else if ($codepoint <= 0x7ff)
    1082710809                {
    10828                         return $cache[$codepoint] = chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f));
     10810                        return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f));
    1082910811                }
    1083010812                else if ($codepoint <= 0xffff)
    1083110813                {
    10832                         return $cache[$codepoint] = chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
     10814                        return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
    1083310815                }
    1083410816                else if ($codepoint <= 0x10ffff)
    1083510817                {
    10836                         return $cache[$codepoint] = chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
     10818                        return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
    1083710819                }
    1083810820                else
    1083910821                {
    1084010822                        // U+FFFD REPLACEMENT CHARACTER
    10841                         return $cache[$codepoint] = "\xEF\xBF\xBD";
     10823                        return "\xEF\xBF\xBD";
    1084210824                }
    1084310825        }
Note: See TracChangeset for help on using the changeset viewer.