Simplify the access to DBO::$data
authorAlexander Ebert <ebert@woltlab.com>
Fri, 18 Feb 2022 17:10:41 +0000 (18:10 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 18 Feb 2022 17:10:41 +0000 (18:10 +0100)
The new code is a bit more precise and is 2-3x times faster. It is not much, but this method is called thousands of times on average requests.

wcfsetup/install/files/lib/data/DatabaseObject.class.php

index dca654de36072a15016b90b010da34d3447eb0b6..ccae53c86330da540b3cf4d6bdf925b4fd3d740c 100644 (file)
@@ -98,11 +98,7 @@ abstract class DatabaseObject implements IIDObject, IStorableObject
      */
     public function __get($name)
     {
-        if (isset($this->data[$name])) {
-            return $this->data[$name];
-        } else {
-            return;
-        }
+        return $this->data[$name] ?? null;
     }
 
     /**