Skip to content

Commit

Permalink
[Bridge] Improve performance for correctly written whitelist.txt
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
logmanoriginal committed Jun 6, 2019
1 parent d4e867f commit e2e0ced
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down

0 comments on commit e2e0ced

Please sign in to comment.