20% performance improvement, since magic getters are very slow
authorTorben-Brodt <t.brodt@gmail.com>
Fri, 25 Nov 2011 16:06:35 +0000 (17:06 +0100)
committerTorben-Brodt <t.brodt@gmail.com>
Fri, 25 Nov 2011 16:06:35 +0000 (17:06 +0100)
wcfsetup/install/files/lib/data/DatabaseObject.class.php

index 1887ae0f0e8f4cc34f229b70251aa0bd2b8c393e..d7ffd13c517b2768ecab4202ac38a24ac16d8e72 100644 (file)
@@ -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