don't call getChildren() thrice

This commit is contained in:
Maximilian 2019-04-27 19:21:38 +02:00 committed by GitHub
parent e244ba4775
commit 833f029335
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -199,11 +199,12 @@ void ThingTypeManager::loadOtb(const std::string& file)
root->skip(128); // description
}
BinaryTreeVec children = root->getChildren();
m_reverseItemTypes.clear();
m_itemTypes.resize(root->getChildren().size() + 1, m_nullItemType);
m_reverseItemTypes.resize(root->getChildren().size() + 1, m_nullItemType);
m_itemTypes.resize(children.size() + 1, m_nullItemType);
m_reverseItemTypes.resize(children.size() + 1, m_nullItemType);
for(const BinaryTreePtr& node : root->getChildren()) {
for(const BinaryTreePtr& node : children) {
ItemTypePtr itemType(new ItemType);
itemType->unserialize(node);
addItemType(itemType);