Only sort the list when required

remotes/origin/etag-endpoint
Joas Schilling 10 years ago
parent 37b827f0b2
commit 3b7aec1b7d
  1. 11
      lib/private/previewmanager.php

@ -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() {
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;
}

Loading…
Cancel
Save