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:
Ingo Schommer 2012-05-04 00:26:09 +02:00
parent f7e19ca680
commit 20a837947f

View File

@ -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
*/
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)) {
$parent = get_parent_class($class);
if (!$parent || !isset($parent::$$name) || $parent::$$name !== $class::$$name) return $class::$$name;
}
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
static $static_properties = array();