From e2e0ced055c4a0ec59415ca00422b1db7fec68e9 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Thu, 6 Jun 2019 20:59:29 +0200 Subject: [PATCH] [Bridge] Improve performance for correctly written whitelist.txt If the bridge name matches exactly, it is not necessary to perform a strtolower compare of bridges. In some situations this can lead to much faster response times (depending on the amount of bridges in whitelist.txt). --- lib/Bridge.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Bridge.php b/lib/Bridge.php index dc42e79b01f..31607922341 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -283,6 +283,12 @@ protected static function sanitizeBridgeName($name) { $name = $matches[1]; } + // Improve performance for correctly written bridge names + if(in_array($name, self::getBridgeNames())) { + $index = array_search($name, self::getBridgeNames()); + return self::getBridgeNames()[$index]; + } + // The name is valid if a corresponding bridge file is found on disk if(in_array(strtolower($name), array_map('strtolower', self::getBridgeNames()))) { $index = array_search(strtolower($name), array_map('strtolower', self::getBridgeNames()));