mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +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:
@ -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();
|
||||
try{
|
||||
$closure();
|
||||
return $closure();
|
||||
}finally{
|
||||
$this->stopTiming();
|
||||
}
|
||||
|
Reference in New Issue
Block a user