IcingaObjectFieldLoader: return early...

...and save CPU-cycles
This commit is contained in:
Thomas Gelf 2017-04-27 15:44:22 +02:00
parent 6de258730b
commit 220d15c523
1 changed files with 7 additions and 8 deletions

View File

@ -240,14 +240,6 @@ class IcingaObjectFieldLoader
$kill = array();
$columns = array();
$object = $this->object;
$object->invalidateResolveCache();
$vars = $object::fromPlainObject(
$object->toPlainObject(true),
$object->getConnection()
)->vars()->flatten();
$prefixedVars = (object) array();
if ($object instanceof IcingaHost) {
$prefix = 'host.vars.';
} elseif ($object instanceof IcingaService) {
@ -256,6 +248,13 @@ class IcingaObjectFieldLoader
return $elements;
}
$object->invalidateResolveCache();
$vars = $object::fromPlainObject(
$object->toPlainObject(true),
$object->getConnection()
)->vars()->flatten();
$prefixedVars = (object) array();
foreach ($vars as $k => $v) {
$prefixedVars->{$prefix . $k} = $v;
}