Inline the call to `DatabaseObject::__get()`
authorAlexander Ebert <ebert@woltlab.com>
Tue, 16 Apr 2024 15:48:34 +0000 (17:48 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 8 Jun 2024 10:31:07 +0000 (12:31 +0200)
`User::__get()` is called very often on each request, easily stacking up thousands of calls.

On a well populated board list this can easily account for up to 1% of runtime. Inlining the check against `$data` cuts down the time spent inside by up to 2/3.

wcfsetup/install/files/lib/data/user/User.class.php

index 0b77456a76d6610cd47b5cf4f409f1ed2dc6be00..07dc5a769f5d4b6bb5bf6c7bb247e7b448103eb5 100644 (file)
@@ -333,9 +333,7 @@ final class User extends DatabaseObject implements IPopoverObject, IRouteControl
      */
     public function __get($name)
     {
-        $value = parent::__get($name);
-
-        return $value ?? $this->getUserOption($name);
+        return $this->data[$name] ?? $this->getUserOption($name);
     }
 
     /**