Commit a5344e48 authored by Pino Toscano's avatar Pino Toscano
Browse files

Slightly optimize KGmap::addDivision

Cache the result of the division lookup by untranslated name and by
color, since each is done at least once in KGmap::addDivision.
parent 8f1962e0
......@@ -34,8 +34,10 @@ KGmap::~KGmap()
bool KGmap::addDivision(division *d)
{
bool b;
if ( ( getDivision(d -> getUntranslatedName()) == NULL && getDivision(d -> getRGB()) == NULL ) ||
( getDivision(d -> getUntranslatedName()) != NULL && getDivision(d -> getRGB()) == NULL && !d->canAsk(division::eClick) && !getDivision(d -> getUntranslatedName())->canAsk(division::eClick) ) )
const division *divByName = getDivision(d -> getUntranslatedName());
const division *divByColor = getDivision(d -> getRGB());
if ( ( divByName == NULL && divByColor == NULL ) ||
( divByName != NULL && divByColor == NULL && !d->canAsk(division::eClick) && !divByName->canAsk(division::eClick) ) )
{
p_divisions.append(d);
b = true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment