From 5f1bc35195f153fdaf76f64e13715881397e4928 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Fri, 17 Feb 2017 12:50:17 -0500 Subject: [PATCH] Check null before creating $range I'm not sure this will have much of an effect, but every little helps... --- src/NodeVisitor/NodeAtPositionFinder.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/NodeVisitor/NodeAtPositionFinder.php b/src/NodeVisitor/NodeAtPositionFinder.php index 521d940..14c4267 100644 --- a/src/NodeVisitor/NodeAtPositionFinder.php +++ b/src/NodeVisitor/NodeAtPositionFinder.php @@ -15,7 +15,7 @@ class NodeAtPositionFinder extends NodeVisitorAbstract /** * The node at the position, if found * - * @var Node + * @var Node|null */ public $node; @@ -34,9 +34,11 @@ class NodeAtPositionFinder extends NodeVisitorAbstract public function leaveNode(Node $node) { - $range = Range::fromNode($node); - if (!isset($this->node) && $range->includes($this->position)) { - $this->node = $node; + if ($this->node === null) { + $range = Range::fromNode($node); + if ($range->includes($this->position)) { + $this->node = $node; + } } } }