]> source.dussan.org Git - nextcloud-server.git/commitdiff
Only sort the list when required
authorJoas Schilling <nickvergessen@owncloud.com>
Fri, 13 Mar 2015 08:55:13 +0000 (09:55 +0100)
committerJoas Schilling <nickvergessen@owncloud.com>
Mon, 16 Mar 2015 11:44:12 +0000 (12:44 +0100)
lib/private/previewmanager.php

index 81fa1baad611df07b3151607e2da24f4240354c7..0d3ec40c06bbb4e04937fa445c9f682a814c0d68 100644 (file)
@@ -15,6 +15,9 @@ class PreviewManager implements IPreview {
        /** @var \OCP\IConfig */
        protected $config;
 
+       /** @var array */
+       protected $providerListDirty = false;
+
        /** @var array */
        protected $providers = [];
 
@@ -57,6 +60,7 @@ class PreviewManager implements IPreview {
                        $this->providers[$mimeTypeRegex] = [];
                }
                $this->providers[$mimeTypeRegex][] = $callable;
+               $this->providerListDirty = true;
        }
 
        /**
@@ -64,8 +68,15 @@ class PreviewManager implements IPreview {
         * @return array
         */
        public function getProviders() {
-               $keys = array_map('strlen', array_keys($this->providers));
-               array_multisort($keys, SORT_DESC, $this->providers);
+               if (!$this->config->getSystemValue('enable_previews', true)) {
+                       return [];
+               }
+
+               if ($this->providerListDirty) {
+                       $keys = array_map('strlen', array_keys($this->providers));
+                       array_multisort($keys, SORT_DESC, $this->providers);
+                       $this->providerListDirty = false;
+               }
 
                return $this->providers;
        }