Cache ClassInfo::class_name() calls

This commit is contained in:
Loz Calver 2017-07-05 15:15:08 +01:00
parent aafa054cf7
commit e3e16fe835

View File

@ -64,6 +64,14 @@ class ClassInfo
*/
private static $_cache_parse = [];
/**
* Cache for class_name
*
* @internal
* @var array
*/
private static $_cache_class_names = [];
/**
* @todo Move this to SS_Database or DB
*
@ -200,8 +208,14 @@ class ClassInfo
if (is_object($nameOrObject)) {
return get_class($nameOrObject);
}
$reflection = new ReflectionClass($nameOrObject);
return $reflection->getName();
$key = strtolower($nameOrObject);
if (!isset(static::$_cache_class_names[$key])) {
$reflection = new ReflectionClass($nameOrObject);
static::$_cache_class_names[$key] = $reflection->getName();
}
return static::$_cache_class_names[$key];
}
/**