From b069789c78fdd1d33eff4b4f6c71a9883f1890a1 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Wed, 13 Feb 2008 03:38:39 +0000 Subject: removed the array_diff comparison in _reindex_segments(). That conditional and use of those functions is probably slower than looping through both arrays, even if someone went crazy with dozens of URI segments. --- system/libraries/URI.php | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'system') diff --git a/system/libraries/URI.php b/system/libraries/URI.php index 8de26f933..aecf05138 100644 --- a/system/libraries/URI.php +++ b/system/libraries/URI.php @@ -245,30 +245,23 @@ class CI_URI { */ function _reindex_segments() { - // Is the routed segment array different then the main segment array? - // have to compute the diff both ways since PHP returns only values in $arr1 that are not in $arr2. - $diff = (array_diff($this->rsegments, $this->segments) != array_diff($this->segments, $this->rsegments)) ? TRUE : FALSE; - $i = 1; + foreach ($this->segments as $val) { $this->segments[$i++] = $val; } + unset($this->segments[0]); - if ($diff == FALSE) - { - $this->rsegments = $this->segments; - } - else + $i = 1; + + foreach ($this->rsegments as $val) { - $i = 1; - foreach ($this->rsegments as $val) - { - $this->rsegments[$i++] = $val; - } - unset($this->rsegments[0]); + $this->rsegments[$i++] = $val; } + + unset($this->rsegments[0]); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b