From: Torben-Brodt Date: Fri, 25 Nov 2011 16:06:35 +0000 (+0100) Subject: 20% performance improvement, since magic getters are very slow X-Git-Tag: 2.0.0_Beta_1~1458^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a0e4cfdc43f3a0d3f1d22c19381969a17caa858d;p=GitHub%2FWoltLab%2FWCF.git 20% performance improvement, since magic getters are very slow --- 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