Merge pull request #7133 from kinglozzer/cache-classname

Cache ClassInfo::class_name() calls
This commit is contained in:
Daniel Hensby 2017-07-10 13:23:45 +01:00 committed by GitHub
commit b2831b809c

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);
}
$key = strtolower($nameOrObject);
if (!isset(static::$_cache_class_names[$key])) {
$reflection = new ReflectionClass($nameOrObject);
return $reflection->getName();
static::$_cache_class_names[$key] = $reflection->getName();
}
return static::$_cache_class_names[$key];
}
/**