From 024a924b38aaf87c60e9eedc86b86c5b8d9f9aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 22 Jul 2016 14:12:45 +0200 Subject: [PATCH] Avoid calculating strlen twice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- libraries/plugins/auth/AuthenticationCookie.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/plugins/auth/AuthenticationCookie.php b/libraries/plugins/auth/AuthenticationCookie.php index 9fa7560383..006aaf7d67 100644 --- a/libraries/plugins/auth/AuthenticationCookie.php +++ b/libraries/plugins/auth/AuthenticationCookie.php @@ -664,11 +664,12 @@ class AuthenticationCookie extends AuthenticationPlugin { // Grab first part, up to 16 chars // The MAC and AES secrets can overlap if original secret is short - if (strlen($secret) > 16) { + $length = strlen($secret); + if ($length > 16) { return substr($secret, 0, 16); } return $this->enlargeSecret( - strlen($secret) == 1 ? $secret : substr($secret, 0, -1) + $length == 1 ? $secret : substr($secret, 0, -1) ); } @@ -683,11 +684,12 @@ class AuthenticationCookie extends AuthenticationPlugin { // Grab second part, up to 16 chars // The MAC and AES secrets can overlap if original secret is short - if (strlen($secret) > 16) { + $length = strlen($secret); + if ($length > 16) { return substr($secret, -16); } return $this->enlargeSecret( - strlen($secret) == 1 ? $secret : substr($secret, 1) + $length == 1 ? $secret : substr($secret, 1) ); }