summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2008-02-13 04:38:39 +0100
committerDerek Jones <derek.jones@ellislab.com>2008-02-13 04:38:39 +0100
commitb069789c78fdd1d33eff4b4f6c71a9883f1890a1 (patch)
tree80e5484d89d8de26598b2c47dfe0fc35a024e985
parent881a79e0ce32bc579ff58449c85e183b96227615 (diff)
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.
-rw-r--r--system/libraries/URI.php23
-rw-r--r--user_guide/changelog.html1
2 files changed, 9 insertions, 15 deletions
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]);
}
// --------------------------------------------------------------------
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index dc3cabca8..78a3d9876 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -78,6 +78,7 @@ Change Log
<li>Modified xss_clean() to be more intelligent with its handling of URL encoded strings.</li>
<li>Added $_SERVER, $_FILES, $_ENV, and $_SESSION to sanitization of globals.</li>
<li>Added a <a href="./helpers/path_helper.html">Path Helper</a>.</li>
+ <li>Simplified _reindex_segments() in the URI class</li>
</ul>
</li>
</ul>