From a0e4cfdc43f3a0d3f1d22c19381969a17caa858d Mon Sep 17 00:00:00 2001 From: Torben-Brodt Date: Fri, 25 Nov 2011 17:06:35 +0100 Subject: [PATCH] 20% performance improvement, since magic getters are very slow --- .../files/lib/data/DatabaseObject.class.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/lib/data/DatabaseObject.class.php b/wcfsetup/install/files/lib/data/DatabaseObject.class.php index 1887ae0f0e..d7ffd13c51 100644 --- a/wcfsetup/install/files/lib/data/DatabaseObject.class.php +++ b/wcfsetup/install/files/lib/data/DatabaseObject.class.php @@ -166,20 +166,22 @@ abstract class DatabaseObject implements IStorableObject { protected static function compareObjects($objectA, $objectB) { foreach (static::$sortBy as $key => $sortBy) { $sortOrder = (isset(static::$sortOrder[$key]) ? static::$sortOrder[$key] : 'ASC'); - if (is_numeric($objectA->$sortBy) && is_numeric($objectB->$sortBy)) { - if ($objectA->$sortBy > $objectB->$sortBy) { + $valA = $objectA->$sortBy; + $valB = $objectB->$sortBy; + if (is_numeric($valA) && is_numeric($valB)) { + if ($valA > $valB) { return ($sortOrder == 'ASC' ? 1 : 0); } - else if ($objectA->$sortBy < $objectB->$sortBy) { + else if ($valA < $valB) { return ($sortOrder == 'ASC' ? 0 : 1); } } else { if ($sortOrder == 'ASC') { - $result = strcoll($objectA->$sortBy, $objectB->$sortBy); + $result = strcoll($valA, $valB); } else { - $result = strcoll($objectB->$sortBy, $objectA->$sortBy); + $result = strcoll($valB, $valA); } if ($result != 0.0) { @@ -190,4 +192,4 @@ abstract class DatabaseObject implements IStorableObject { return 0; } -} +} \ No newline at end of file -- 2.20.1