diff --git a/cocos/2d/CCActionInterval.cpp b/cocos/2d/CCActionInterval.cpp index 404416be59..b265aca9d2 100644 --- a/cocos/2d/CCActionInterval.cpp +++ b/cocos/2d/CCActionInterval.cpp @@ -2237,7 +2237,7 @@ bool Animate::initWithAnimation(Animation* animation) float accumUnitsOfTime = 0; float newUnitOfTimeValue = singleDuration / animation->getTotalDelayUnits(); - auto frames = animation->getFrames(); + auto& frames = animation->getFrames(); for (auto& frame : frames) { @@ -2312,7 +2312,7 @@ void Animate::update(float t) t = fmodf(t, 1.0f); } - auto frames = _animation->getFrames(); + auto& frames = _animation->getFrames(); auto numberOfFrames = frames.size(); SpriteFrame *frameToDisplay = nullptr; @@ -2346,7 +2346,7 @@ void Animate::update(float t) Animate* Animate::reverse() const { - auto oldArray = _animation->getFrames(); + auto& oldArray = _animation->getFrames(); Vector newArray(oldArray.size()); if (oldArray.size() > 0) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 24365d63f1..e54d7ee6b7 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -592,12 +592,12 @@ void Label::alignText() batchNode->getTextureAtlas()->removeAllQuads(); } _fontAtlas->prepareLetterDefinitions(_currentUTF16String); - auto textures = _fontAtlas->getTextures(); + auto& textures = _fontAtlas->getTextures(); if (textures.size() > _batchNodes.size()) { for (auto index = _batchNodes.size(); index < textures.size(); ++index) { - auto batchNode = SpriteBatchNode::createWithTexture(textures[index]); + auto batchNode = SpriteBatchNode::createWithTexture(textures.at(index)); batchNode->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT); batchNode->setPosition(Vec2::ZERO); Node::addChild(batchNode,0,Node::INVALID_TAG); @@ -630,9 +630,9 @@ void Label::alignText() uvRect.origin.x = _lettersInfo[tag].def.U; uvRect.origin.y = _lettersInfo[tag].def.V; - letterSprite->setTexture(textures[_lettersInfo[tag].def.textureID]); + letterSprite->setTexture(textures.at(_lettersInfo[tag].def.textureID)); letterSprite->setTextureRect(uvRect); - } + } } } diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp index 198d25cfe7..30e267aa8b 100644 --- a/cocos/base/CCConsole.cpp +++ b/cocos/base/CCConsole.cpp @@ -161,14 +161,14 @@ static void printFileUtils(int fd) FileUtils* fu = FileUtils::getInstance(); mydprintf(fd, "\nSearch Paths:\n"); - auto list = fu->getSearchPaths(); + auto& list = fu->getSearchPaths(); for( const auto &item : list) { mydprintf(fd, "%s\n", item.c_str()); } mydprintf(fd, "\nResolution Order:\n"); - list = fu->getSearchResolutionsOrder(); - for( const auto &item : list) { + auto& list1 = fu->getSearchResolutionsOrder(); + for( const auto &item : list1) { mydprintf(fd, "%s\n", item.c_str()); } @@ -176,7 +176,7 @@ static void printFileUtils(int fd) mydprintf(fd, "%s\n", fu->getWritablePath().c_str()); mydprintf(fd, "\nFull Path Cache:\n"); - auto cache = fu->getFullPathCache(); + auto& cache = fu->getFullPathCache(); for( const auto &item : cache) { mydprintf(fd, "%s -> %s\n", item.first.c_str(), item.second.c_str()); } diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp index 052f25b4f7..3f60a792ff 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp @@ -204,7 +204,7 @@ void foreachNodeDescendant(Node* parent, tCallBack callback) { callback(parent); - auto children = parent->getChildren(); + auto& children = parent->getChildren(); for (auto child : children) { foreachNodeDescendant(child, callback); diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 6274d514d0..a9f953e865 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -1696,7 +1696,7 @@ bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction)c return true; } - auto container = parent->getChildren(); + auto& container = parent->getChildren(); ssize_t index = container.getIndex(widget); if (parent->getLayoutType() == Type::HORIZONTAL) {