Permalink
Browse files

Improve the performance of findLayerByName() a little bit

[How] do the type-match test first
  • Loading branch information...
chchwy committed Dec 12, 2017
1 parent 80fec67 commit 70b46cc7d39a22e147c8236077a2be2c4d380058
Showing with 2 additions and 4 deletions.
  1. +2 −4 core_lib/structure/object.cpp
@@ -250,12 +250,10 @@ Layer* Object::getLayer(int i) const
Layer* Object::findLayerByName(QString strName, Layer::LAYER_TYPE type) const
{
bool bCheckType = (type != Layer::UNDEFINED);
for (Layer* layer : mLayers)
{
bool bTypeMatch = (bCheckType) ? (type == layer->type()) : true;
if (layer->name() == strName && bTypeMatch)
bool isTypeMatch = (bCheckType) ? (type == layer->type()) : true;
if (isTypeMatch && layer->name() == strName)
{
return layer;
}

0 comments on commit 70b46cc

Please sign in to comment.