mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-17 22:28:22 +01:00
[Bridge] Use static variable in listBridges()
This prevents the function from re-loading the same data over and over again. Instead the same data is returned on each call, during a single request.
This commit is contained in:
parent
e26d61ec0a
commit
3bb3353897
@ -70,13 +70,17 @@ EOD;
|
||||
* @return array List of the bridges
|
||||
*/
|
||||
static public function listBridges(){
|
||||
$listBridge = array();
|
||||
$dirFiles = scandir(self::getDir());
|
||||
|
||||
if($dirFiles !== false) {
|
||||
foreach($dirFiles as $fileName) {
|
||||
if(preg_match('@^([^.]+)Bridge\.php$@U', $fileName, $out)) {
|
||||
$listBridge[] = $out[1];
|
||||
static $listBridge = array(); // Initialized on first call
|
||||
|
||||
if(empty($listBridge)) {
|
||||
$dirFiles = scandir(self::getDir());
|
||||
|
||||
if($dirFiles !== false) {
|
||||
foreach($dirFiles as $fileName) {
|
||||
if(preg_match('@^([^.]+)Bridge\.php$@U', $fileName, $out)) {
|
||||
$listBridge[] = $out[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user