Skip to content

Commit fa2dab1

Browse files
committed
Optimize perf by replacing call_user_func with dynamic vars
1 parent 9e4dc57 commit fa2dab1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

XPath/Translator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function nodeToXPath(NodeInterface $node): XPathExpr
155155
throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName()));
156156
}
157157

158-
return \call_user_func($this->nodeTranslators[$node->getNodeName()], $node, $this);
158+
return $this->nodeTranslators[$node->getNodeName()]($node, $this);
159159
}
160160

161161
/**
@@ -167,7 +167,7 @@ public function addCombination(string $combiner, NodeInterface $xpath, NodeInter
167167
throw new ExpressionErrorException(sprintf('Combiner "%s" not supported.', $combiner));
168168
}
169169

170-
return \call_user_func($this->combinationTranslators[$combiner], $this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
170+
return $this->combinationTranslators[$combiner]($this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
171171
}
172172

173173
/**
@@ -179,7 +179,7 @@ public function addFunction(XPathExpr $xpath, FunctionNode $function): XPathExpr
179179
throw new ExpressionErrorException(sprintf('Function "%s" not supported.', $function->getName()));
180180
}
181181

182-
return \call_user_func($this->functionTranslators[$function->getName()], $xpath, $function);
182+
return $this->functionTranslators[$function->getName()]($xpath, $function);
183183
}
184184

185185
/**
@@ -191,7 +191,7 @@ public function addPseudoClass(XPathExpr $xpath, string $pseudoClass): XPathExpr
191191
throw new ExpressionErrorException(sprintf('Pseudo-class "%s" not supported.', $pseudoClass));
192192
}
193193

194-
return \call_user_func($this->pseudoClassTranslators[$pseudoClass], $xpath);
194+
return $this->pseudoClassTranslators[$pseudoClass]($xpath);
195195
}
196196

197197
/**
@@ -203,7 +203,7 @@ public function addAttributeMatching(XPathExpr $xpath, string $operator, string
203203
throw new ExpressionErrorException(sprintf('Attribute matcher operator "%s" not supported.', $operator));
204204
}
205205

206-
return \call_user_func($this->attributeMatchingTranslators[$operator], $xpath, $attribute, $value);
206+
return $this->attributeMatchingTranslators[$operator]($xpath, $attribute, $value);
207207
}
208208

209209
/**

0 commit comments

Comments
 (0)