mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +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();
|
||||
try{
|
||||
$closure();
|
||||
return $closure();
|
||||
}finally{
|
||||
$this->stopTiming();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user