summaryrefslogtreecommitdiffstats
path: root/application/libraries
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-09-20 11:09:22 +0200
committerFlorian Pritz <bluewind@xinu.at>2015-09-20 11:09:22 +0200
commitf149a0d1abb4a79b1d5de9ddb5963b2eab4b126d (patch)
tree2585c69f208c7547309a18cb9767e045229d48ca /application/libraries
parentf4c47ee5b72f6074827cc86b28d0ab4031be7237 (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.php13
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];
}
/**