mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 10:01:53 +00:00
TimingsHandler: return the result of $closure() for easier usage
this isn't type safe, but it doesn't matter a whole lot, and there's nothing we can do about it without generics.
This commit is contained in:
parent
de6053de11
commit
858f440bcf
@ -184,10 +184,15 @@ class TimingsHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function time(\Closure $closure) : void{
|
/**
|
||||||
|
* @param \Closure $closure
|
||||||
|
*
|
||||||
|
* @return mixed the result of the given closure
|
||||||
|
*/
|
||||||
|
public function time(\Closure $closure){
|
||||||
$this->startTiming();
|
$this->startTiming();
|
||||||
try{
|
try{
|
||||||
$closure();
|
return $closure();
|
||||||
}finally{
|
}finally{
|
||||||
$this->stopTiming();
|
$this->stopTiming();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user