Derek Jones avatar Derek Jones committed 82a5038

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.

Comments (0)

Files changed (2)


 	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;
-		$i = 1;
 		foreach ($this->segments as $val)
 			$this->segments[$i++] = $val;
-		if ($diff == FALSE)
+		$i = 1;
+		foreach ($this->rsegments as $val)
-			$this->rsegments = $this->segments;
+			$this->rsegments[$i++] = $val;
-		else
-		{
-			$i = 1;
-			foreach ($this->rsegments as $val)
-			{
-				$this->rsegments[$i++] = $val;
-			}
-			unset($this->rsegments[0]);
-		}
+		unset($this->rsegments[0]);
 	// --------------------------------------------------------------------


 			<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>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.