Optimize DynamicObject::HasAuthority().

Refs #5049
This commit is contained in:
Gunnar Beutner 2013-11-11 08:22:58 +01:00
parent f7171e3e90
commit eb746b9929
3 changed files with 5 additions and 7 deletions

View File

@ -47,9 +47,6 @@ struct ServiceNextCheckExtractor
*/ */
double operator()(const Service::Ptr& service) double operator()(const Service::Ptr& service)
{ {
if (!service->HasAuthority("checker"))
return Utility::GetTime() + 60;
return service->GetNextCheck(); return service->GetNextCheck();
} }
}; };

View File

@ -74,6 +74,9 @@ void DynamicObject::SetAuthority(const String& type, bool value)
if (old_value == value) if (old_value == value)
return; return;
if (GetAuthorityInfo() == NULL)
SetAuthorityInfo(make_shared<Dictionary>());
GetAuthorityInfo()->Set(type, value); GetAuthorityInfo()->Set(type, value);
} }
@ -84,7 +87,7 @@ bool DynamicObject::HasAuthority(const String& type) const
{ {
Dictionary::Ptr authorityInfo = GetAuthorityInfo(); Dictionary::Ptr authorityInfo = GetAuthorityInfo();
if (!authorityInfo->Contains(type)) if (!authorityInfo || !authorityInfo->Contains(type))
return true; return true;
return authorityInfo->Get(type); return authorityInfo->Get(type);

View File

@ -10,9 +10,7 @@ abstract class DynamicObject
[config] Array::Ptr domains; [config] Array::Ptr domains;
[config] Array::Ptr authorities; [config] Array::Ptr authorities;
[get_protected] bool active; [get_protected] bool active;
Dictionary::Ptr authority_info { Dictionary::Ptr authority_info;
default {{{ return make_shared<Dictionary>(); }}}
};
[protected] Dictionary::Ptr extensions; [protected] Dictionary::Ptr extensions;
}; };