I am profiling my code in php. Question is about next function:
// returns true if edge exists in the tree
protected function edgeExist( $srcNodeId, $firstToken ) {
$result = array_key_exists( $srcNodeId, $this->edges )
&& array_key_exists( $firstToken, $this->edges[$srcNodeId]);
return $result;
}
According to the profiler, function edgeExist consumes about 10% of running time, but function array_key_exists consumes about 0.2% of running time.
Why does function edgeExist consume so much?
This could be faster, try it:
There is a small difference when using
array_key_exists()andisset(). Look in to the manual.