mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-21 02:16:33 +00:00
RegistryTrait: added fast path optimization
this reduces VanillaBlocks access time from 360 ns to 230 ns on my machine - an improvement of about 35%.
This commit is contained in:
parent
9f3533d870
commit
1de66cb0de
@ -114,6 +114,13 @@ trait RegistryTrait{
|
||||
if(count($arguments) > 0){
|
||||
throw new \ArgumentCountError("Expected exactly 0 arguments, " . count($arguments) . " passed");
|
||||
}
|
||||
|
||||
//fast path
|
||||
if(self::$members !== null && isset(self::$members[$name])){
|
||||
return self::preprocessMember(self::$members[$name]);
|
||||
}
|
||||
|
||||
//fallback
|
||||
try{
|
||||
return self::_registryFromString($name);
|
||||
}catch(\InvalidArgumentException $e){
|
||||
|
Loading…
x
Reference in New Issue
Block a user