mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-30 05:09:06 +02:00
MINOR Using PHP version constants rather than version_compare() in Object::static_lookup(), since its called 10k times on an average CMS load that makes a difference of about 3% (with APC)
This commit is contained in:
parent
f7e19ca680
commit
20a837947f
@ -290,14 +290,13 @@ abstract class Object {
|
|||||||
* @return any - The value of the static property $name on class $class, or $default if that property is not defined
|
* @return any - The value of the static property $name on class $class, or $default if that property is not defined
|
||||||
*/
|
*/
|
||||||
public static function static_lookup($class, $name, $default = null) {
|
public static function static_lookup($class, $name, $default = null) {
|
||||||
if (version_compare(PHP_VERSION, '5.4', '>=') && is_subclass_of($class, 'Object')) {
|
if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4 && is_subclass_of($class, 'Object')) {
|
||||||
if (isset($class::$$name)) {
|
if (isset($class::$$name)) {
|
||||||
$parent = get_parent_class($class);
|
$parent = get_parent_class($class);
|
||||||
if (!$parent || !isset($parent::$$name) || $parent::$$name !== $class::$$name) return $class::$$name;
|
if (!$parent || !isset($parent::$$name) || $parent::$$name !== $class::$$name) return $class::$$name;
|
||||||
}
|
}
|
||||||
return $default;
|
return $default;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// TODO: This gets set once, then not updated, so any changes to statics after this is called the first time for any class won't be exposed
|
// TODO: This gets set once, then not updated, so any changes to statics after this is called the first time for any class won't be exposed
|
||||||
static $static_properties = array();
|
static $static_properties = array();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user