diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-09-20 11:09:22 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-09-20 11:09:22 +0200 |
commit | f149a0d1abb4a79b1d5de9ddb5963b2eab4b126d (patch) | |
tree | 2585c69f208c7547309a18cb9767e045229d48ca /application/libraries | |
parent | f4c47ee5b72f6074827cc86b28d0ab4031be7237 (diff) |
l/Image::type_supported: improve performance
service/file::history calls this for every entry which is rather slow.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/libraries')
-rw-r--r-- | application/libraries/Image.php | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/application/libraries/Image.php b/application/libraries/Image.php index c6cd20d06..18814e181 100644 --- a/application/libraries/Image.php +++ b/application/libraries/Image.php @@ -131,15 +131,22 @@ class Image { */ public static function type_supported($mimetype) { + static $cache = array(); + if (isset($cache[$mimetype])) { + return $cache[$mimetype]; + } + try { $driver = self::best_driver(self::get_image_drivers(), $mimetype); + $cache[$mimetype] = true; } catch (\exceptions\ApiException $e) { if ($e->get_error_id() == "libraries/Image/unsupported-image-type") { - return false; + $cache[$mimetype] = false; + } else { + throw $e; } - throw $e; } - return true; + return $cache[$mimetype]; } /** |