diff --git a/cocos/ui/UIRichText.cpp b/cocos/ui/UIRichText.cpp index 7aa03e717a..411b60b473 100644 --- a/cocos/ui/UIRichText.cpp +++ b/cocos/ui/UIRichText.cpp @@ -1733,13 +1733,12 @@ void RichText::formarRenderers() Vector* row = element; float nextPosX = 0.0f; float maxY = 0.0f; - for (ssize_t j=0, size = row->size(); jat(j); - l->setAnchorPoint(Vec2::ZERO); - l->setPosition(nextPosX, nextPosY); - this->addProtectedChild(l, 1); - Size iSize = l->getContentSize(); + iter->setAnchorPoint(Vec2::ZERO); + iter->setPosition(nextPosX, nextPosY); + this->addProtectedChild(iter, 1); + Size iSize = iter->getContentSize(); newContentSizeWidth += iSize.width; nextPosX += iSize.width; maxY = MAX(maxY, iSize.height); @@ -1757,10 +1756,9 @@ void RichText::formarRenderers() { Vector* row = (_elementRenders[i]); float maxHeight = 0.0f; - for (ssize_t j=0, size = row->size(); jat(j); - maxHeight = MAX(l->getContentSize().height, maxHeight); + maxHeight = MAX(iter->getContentSize().height, maxHeight); } maxHeights[i] = maxHeight; newContentSizeHeight += maxHeights[i]; @@ -1773,25 +1771,22 @@ void RichText::formarRenderers() float nextPosX = 0.0f; nextPosY -= (maxHeights[i] + _defaults.at(KEY_VERTICAL_SPACE).asFloat()); - for (ssize_t j=0, size = row->size(); jat(j); - l->setAnchorPoint(Vec2::ZERO); - l->setPosition(nextPosX, nextPosY); - this->addProtectedChild(l, 1); - nextPosX += l->getContentSize().width; + iter->setAnchorPoint(Vec2::ZERO); + iter->setPosition(nextPosX, nextPosY); + this->addProtectedChild(iter, 1); + nextPosX += iter->getContentSize().width; } } delete [] maxHeights; } - size_t length = _elementRenders.size(); - for (size_t i = 0; i* l = _elementRenders[i]; - l->clear(); - delete l; - } + for (auto& iter : _elementRenders) + { + iter->clear(); + delete iter; + } _elementRenders.clear(); if (_ignoreSize)