From 2f57a7fb18cbbe207dcb0f89cd6c66ab6e7e47b1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 1 Jul 2013 23:06:56 -0400 Subject: [PATCH] Use simpler and faster code. substr_compare() is up to 2x slower than just substr(). Use a faster, more common, and simpler to read variant of the same thing. --- lib/Cake/Network/CakeRequest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index f7d745f82bf..8b7e33e42dd 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -261,7 +261,10 @@ protected function _url() { } $endsWithIndex = '/webroot/index.php'; $endsWithLength = strlen($endsWithIndex); - if (strlen($uri) >= $endsWithLength && substr_compare($uri, $endsWithIndex, -$endsWithLength, $endsWithLength) === 0) { + if ( + strlen($uri) >= $endsWithLength && + substr($uri, -$endsWithLength) == $endsWithIndex + ) { $uri = '/'; } return $uri;