Merge pull request #1030 from Shawak/patch-1

don't call getChildren() thrice
This commit is contained in:
Konrad Kuśnierz 2019-04-28 10:40:20 +02:00 committed by GitHub
commit fdba9d5e9c
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 root->skip(128); // description
} }
BinaryTreeVec children = root->getChildren();
m_reverseItemTypes.clear(); m_reverseItemTypes.clear();
m_itemTypes.resize(root->getChildren().size() + 1, m_nullItemType); m_itemTypes.resize(children.size() + 1, m_nullItemType);
m_reverseItemTypes.resize(root->getChildren().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); ItemTypePtr itemType(new ItemType);
itemType->unserialize(node); itemType->unserialize(node);
addItemType(itemType); addItemType(itemType);