mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #7133 from kinglozzer/cache-classname
Cache ClassInfo::class_name() calls
This commit is contained in:
commit
b2831b809c
@ -64,6 +64,14 @@ class ClassInfo
|
|||||||
*/
|
*/
|
||||||
private static $_cache_parse = [];
|
private static $_cache_parse = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache for class_name
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private static $_cache_class_names = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Move this to SS_Database or DB
|
* @todo Move this to SS_Database or DB
|
||||||
*
|
*
|
||||||
@ -200,8 +208,14 @@ class ClassInfo
|
|||||||
if (is_object($nameOrObject)) {
|
if (is_object($nameOrObject)) {
|
||||||
return get_class($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];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user