]> source.dussan.org Git - nextcloud-server.git/commitdiff
Skip already loaded apps in loadApps 23940/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Fri, 6 Nov 2020 13:26:42 +0000 (14:26 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Fri, 6 Nov 2020 13:56:06 +0000 (14:56 +0100)
Otherwise you might end up calling a lot of functions unneeded.
And while the individual calls are cheap if you multiply them by 20k
they still get somewhat expensive.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
lib/private/legacy/OC_App.php

index d2f8e53600566b51ae0e71682b1fdb16f3ad59ef..941cd25397d65f44889f5021354c2e9c28b65498 100644 (file)
@@ -94,7 +94,7 @@ class OC_App {
         * @return bool
         */
        public static function isAppLoaded(string $app): bool {
-               return in_array($app, self::$loadedApps, true);
+               return isset(self::$loadedApps[$app]);
        }
 
        /**
@@ -127,7 +127,7 @@ class OC_App {
                // prevent app.php from printing output
                ob_start();
                foreach ($apps as $app) {
-                       if (($types === [] or self::isType($app, $types)) && !in_array($app, self::$loadedApps)) {
+                       if (!isset(self::$loadedApps[$app]) && ($types === [] || self::isType($app, $types))) {
                                self::loadApp($app);
                        }
                }
@@ -143,7 +143,7 @@ class OC_App {
         * @throws Exception
         */
        public static function loadApp(string $app) {
-               self::$loadedApps[] = $app;
+               self::$loadedApps[$app] = true;
                $appPath = self::getAppPath($app);
                if ($appPath === false) {
                        return;