From: Robert Sesek Date: Sat, 6 Aug 2011 19:18:04 +0000 (-0400) Subject: More optimizations by caching the value of IsRequired() X-Git-Tag: api-2~60 X-Git-Url: https://src.bluestatic.org/?a=commitdiff_plain;h=037d7425fee007af6edb43affbd8e9ed9c5f32d1;p=hoplite.git More optimizations by caching the value of IsRequired() --- diff --git a/base/weak_interface.php b/base/weak_interface.php index 7d16b08..5f73f9d 100644 --- a/base/weak_interface.php +++ b/base/weak_interface.php @@ -121,11 +121,15 @@ class MethodImp /*! @var ReflectionMethod The method of the actual interface that this is implementing. */ private $method = NULL; + /*! @var bool Whether or not this is required. */ + private $required = FALSE; + public function __construct(\hoplite\base\WeakInterface $interface, \ReflectionMethod $method) { $this->interface = $interface; $this->method = $method; + $this->required = strpos($this->method->GetDocComment(), '@required') !== FALSE; } /*! Forwards a method call. */ @@ -134,7 +138,7 @@ class MethodImp try { $impl = $reflector->GetMethod($this->method->name); } catch (\ReflectionException $e) { - if ($this->IsRequired()) + if ($this->required) throw $e; return; } @@ -150,7 +154,7 @@ class MethodImp /*! Checks if a method is marked as required. */ public function IsRequired() { - return strpos($this->method->GetDocComment(), '@required') !== FALSE; + return $this->required; } }