From 2a2e8a1e95224d0c283a765443fa5e19a165520b Mon Sep 17 00:00:00 2001 From: aismann Date: Thu, 21 Jul 2022 13:19:08 +0200 Subject: [PATCH] Improve c++11 for-loop performance with Universal References (#760) --- core/2d/CCActionInterval.cpp | 2 +- core/2d/CCAnimation.cpp | 4 +- core/2d/CCAnimationCache.cpp | 4 +- core/2d/CCAutoPolygon.cpp | 2 +- core/2d/CCCameraBackgroundBrush.cpp | 2 +- core/2d/CCClippingNode.cpp | 2 +- core/2d/CCComponentContainer.cpp | 8 +- core/2d/CCFastTMXLayer.cpp | 10 +- core/2d/CCFastTMXTiledMap.cpp | 4 +- core/2d/CCFontAtlas.cpp | 6 +- core/2d/CCFontAtlasCache.cpp | 2 +- core/2d/CCLabel.cpp | 10 +- core/2d/CCLabelTextFormatter.cpp | 4 +- core/2d/CCMenu.cpp | 2 +- core/2d/CCNode.cpp | 2 +- core/2d/CCParticleSystem.cpp | 2 +- core/2d/CCPlistSpriteSheetLoader.cpp | 4 +- core/2d/CCProtectedNode.cpp | 20 +-- core/2d/CCSpriteFrameCache.cpp | 4 +- core/3d/CCAnimate3D.cpp | 4 +- core/3d/CCAnimation3D.cpp | 2 +- core/3d/CCBundle3D.cpp | 10 +- core/3d/CCBundle3DData.h | 10 +- core/3d/CCMesh.cpp | 14 +- core/3d/CCMeshMaterial.cpp | 6 +- core/3d/CCMeshRenderer.cpp | 26 +-- core/3d/CCMeshSkin.cpp | 2 +- core/3d/CCMeshVertexIndexData.cpp | 2 +- core/3d/CCSkeleton3D.cpp | 12 +- core/3d/CCTerrain.cpp | 4 +- core/audio/AudioEngineImpl.cpp | 4 +- core/base/CCConsole.cpp | 8 +- core/base/CCController-linux-win32.cpp | 4 +- core/base/CCController.cpp | 4 +- core/base/CCEventDispatcher.cpp | 34 ++-- core/base/CCMap.h | 2 +- core/base/CCProfiling.cpp | 2 +- core/base/CCProperties.cpp | 2 +- core/base/CCScheduler.cpp | 2 +- core/base/CCUserDefault.cpp | 6 +- core/base/CCValue.cpp | 2 +- core/base/CCVector.h | 4 +- core/base/ZipUtils.cpp | 2 +- core/base/astc.cpp | 2 +- core/base/ccUtils.cpp | 6 +- core/navmesh/CCNavMesh.cpp | 18 +- core/navmesh/CCNavMeshDebugDraw.cpp | 6 +- core/network/CCDownloader-curl.cpp | 8 +- core/network/HttpClient.cpp | 2 +- core/network/HttpCookie.cpp | 6 +- core/network/Uri.cpp | 2 +- core/physics/CCPhysicsBody.cpp | 18 +- core/physics/CCPhysicsJoint.cpp | 6 +- core/physics/CCPhysicsShape.cpp | 20 +-- core/physics/CCPhysicsWorld.cpp | 36 ++-- core/physics3d/CCPhysics3DObject.cpp | 4 +- core/physics3d/CCPhysics3DShape.cpp | 4 +- core/physics3d/CCPhysics3DWorld.cpp | 20 +-- core/platform/CCGLView.cpp | 2 +- .../platform/desktop/CCGLViewImpl-desktop.cpp | 4 +- core/renderer/CCMaterial.cpp | 2 +- core/renderer/CCQuadCommand.cpp | 2 +- core/renderer/CCRenderCommandPool.h | 2 +- core/renderer/CCRenderer.cpp | 8 +- core/renderer/CCTextureCache.cpp | 16 +- core/renderer/CCTextureCube.cpp | 2 +- core/renderer/backend/ProgramCache.cpp | 4 +- core/renderer/backend/ProgramState.cpp | 4 +- core/renderer/backend/ShaderCache.cpp | 2 +- .../backend/opengl/CommandBufferGL.cpp | 4 +- core/renderer/backend/opengl/TextureGL.cpp | 2 +- core/ui/LayoutHelper.cpp | 4 +- core/ui/UIHelper.cpp | 6 +- core/ui/UILayout.cpp | 4 +- core/ui/UILayoutComponent.cpp | 2 +- core/ui/UILayoutManager.cpp | 10 +- core/ui/UIListView.cpp | 6 +- core/ui/UIPageViewIndicator.cpp | 14 +- core/ui/UIRichText.cpp | 12 +- core/ui/UIScrollView.cpp | 4 +- core/ui/UITabControl.cpp | 8 +- core/ui/UIWidget.cpp | 6 +- .../GUI/CCControlExtension/CCControl.cpp | 2 +- extensions/Particle3D/CCParticle3DRender.cpp | 8 +- extensions/Particle3D/CCParticleSystem3D.cpp | 4 +- extensions/Particle3D/CCParticleSystem3D.h | 2 +- extensions/Particle3D/PU/CCPUBeamRender.cpp | 2 +- extensions/Particle3D/PU/CCPUBoxCollider.cpp | 2 +- .../PU/CCPUCollisionAvoidanceAffector.cpp | 2 +- .../Particle3D/PU/CCPUColorAffector.cpp | 2 +- .../PU/CCPUDoAffectorEventHandler.cpp | 2 +- .../PU/CCPUDoEnableComponentEventHandler.cpp | 8 +- .../CCPUDoPlacementParticleEventHandler.cpp | 2 +- extensions/Particle3D/PU/CCPUEmitter.cpp | 2 +- .../PU/CCPUFlockCenteringAffector.cpp | 2 +- .../Particle3D/PU/CCPUForceFieldAffector.cpp | 2 +- .../Particle3D/PU/CCPUGeometryRotator.cpp | 4 +- .../Particle3D/PU/CCPUGravityAffector.cpp | 2 +- .../PU/CCPUInterParticleCollider.cpp | 2 +- extensions/Particle3D/PU/CCPUJetAffector.cpp | 2 +- extensions/Particle3D/PU/CCPULineAffector.cpp | 2 +- .../Particle3D/PU/CCPULinearForceAffector.cpp | 2 +- .../Particle3D/PU/CCPUMaterialManager.cpp | 6 +- .../Particle3D/PU/CCPUParticleFollower.cpp | 2 +- .../Particle3D/PU/CCPUParticleSystem3D.cpp | 156 +++++++++--------- extensions/Particle3D/PU/CCPUPathFollower.cpp | 2 +- .../Particle3D/PU/CCPUPlaneCollider.cpp | 2 +- extensions/Particle3D/PU/CCPURandomiser.cpp | 2 +- extensions/Particle3D/PU/CCPURender.cpp | 14 +- extensions/Particle3D/PU/CCPURibbonTrail.cpp | 2 +- .../Particle3D/PU/CCPURibbonTrailRender.cpp | 2 +- .../Particle3D/PU/CCPUScaleAffector.cpp | 2 +- .../PU/CCPUScaleVelocityAffector.cpp | 2 +- .../Particle3D/PU/CCPUScriptCompiler.cpp | 16 +- extensions/Particle3D/PU/CCPUScriptParser.cpp | 2 +- .../Particle3D/PU/CCPUSineForceAffector.cpp | 2 +- extensions/Particle3D/PU/CCPUSlaveEmitter.cpp | 6 +- .../Particle3D/PU/CCPUSphereCollider.cpp | 2 +- .../Particle3D/PU/CCPUTextureAnimator.cpp | 2 +- .../Particle3D/PU/CCPUTextureRotator.cpp | 2 +- .../PU/CCPUVelocityMatchingAffector.cpp | 2 +- .../Particle3D/PU/CCPUVortexAffector.cpp | 2 +- .../ActionTimeline/CCActionTimeline.cpp | 12 +- .../cocostudio/ActionTimeline/CCBoneNode.cpp | 12 +- .../ActionTimeline/CCSkeletonNode.cpp | 4 +- .../cocostudio/ActionTimeline/CCTimeLine.cpp | 4 +- extensions/cocostudio/CCActionManagerEx.cpp | 2 +- extensions/cocostudio/CCActionNode.cpp | 4 +- extensions/cocostudio/CCArmature.cpp | 16 +- extensions/cocostudio/CCArmatureAnimation.cpp | 6 +- extensions/cocostudio/CCBatchNode.cpp | 2 +- extensions/cocostudio/CCBone.cpp | 4 +- extensions/cocostudio/CCColliderDetector.cpp | 16 +- extensions/cocostudio/CCDisplayManager.cpp | 2 +- .../cocostudio/SpineSkeletonDataCache.cpp | 4 +- .../Classes/ActionsTest/ActionsTest.cpp | 2 +- .../Classes/BillBoardTest/BillBoardTest.cpp | 4 +- .../Classes/FileUtilsTest/FileUtilsTest.cpp | 2 +- tests/cpp-tests/Classes/FontTest/FontTest.cpp | 6 +- .../cpp-tests/Classes/LayerTest/LayerTest.cpp | 2 +- .../MaterialSystemTest/MaterialSystemTest.cpp | 2 +- .../MeshRendererTest/MeshRendererTest.cpp | 18 +- .../Classes/NavMeshTest/NavMeshTest.cpp | 6 +- .../Classes/Particle3DTest/Particle3DTest.cpp | 2 +- .../Classes/Physics3DTest/Physics3DTest.cpp | 4 +- .../Classes/PhysicsTest/PhysicsTest.cpp | 2 +- .../Classes/SchedulerTest/SchedulerTest.cpp | 4 +- .../Classes/ShaderTest/ShaderTest2.cpp | 12 +- .../SpritePolygonTest/SpritePolygonTest.cpp | 2 +- .../Classes/SpriteTest/SpriteTest.cpp | 4 +- .../Classes/Texture2dTest/Texture2dTest.cpp | 6 +- .../Classes/TileMapTest/TileMapTest2.cpp | 6 +- .../Classes/TouchesTest/TouchesTest.cpp | 6 +- .../TransitionsTest/TransitionsTest.cpp | 2 +- tests/cpp-tests/Classes/UnitTest/UnitTest.cpp | 12 +- tests/cpp-tests/Classes/controller.cpp | 8 +- tests/fairygui-tests/Classes/EmojiParser.cpp | 2 +- 157 files changed, 518 insertions(+), 518 deletions(-) diff --git a/core/2d/CCActionInterval.cpp b/core/2d/CCActionInterval.cpp index 5601d748f9..4025935c2a 100644 --- a/core/2d/CCActionInterval.cpp +++ b/core/2d/CCActionInterval.cpp @@ -2495,7 +2495,7 @@ bool Animate::initWithAnimation(Animation* animation) auto& frames = animation->getFrames(); - for (auto& frame : frames) + for (auto&& frame : frames) { float value = (accumUnitsOfTime * newUnitOfTimeValue) / singleDuration; accumUnitsOfTime += frame->getDelayUnits(); diff --git a/core/2d/CCAnimation.cpp b/core/2d/CCAnimation.cpp index ab38c7e707..48caf04b63 100644 --- a/core/2d/CCAnimation.cpp +++ b/core/2d/CCAnimation.cpp @@ -121,7 +121,7 @@ bool Animation::initWithSpriteFrames(const Vector& frames, _delayPerUnit = delay; _loops = loops; - for (auto& spriteFrame : frames) + for (auto&& spriteFrame : frames) { auto animFrame = AnimationFrame::create(spriteFrame, 1, ValueMap()); _frames.pushBack(animFrame); @@ -140,7 +140,7 @@ bool Animation::initWithAnimationFrames(const Vector& arrayOfAn setFrames(arrayOfAnimationFrames); - for (auto& animFrame : _frames) + for (auto&& animFrame : _frames) { _totalDelayUnits += animFrame->getDelayUnits(); } diff --git a/core/2d/CCAnimationCache.cpp b/core/2d/CCAnimationCache.cpp index 8b2e1c1921..4b573152c3 100644 --- a/core/2d/CCAnimationCache.cpp +++ b/core/2d/CCAnimationCache.cpp @@ -104,7 +104,7 @@ void AnimationCache::parseVersion1(const ValueMap& animations) ssize_t frameNameSize = frameNames.size(); Vector frames(frameNameSize); - for (auto& frameName : frameNames) + for (auto&& frameName : frameNames) { SpriteFrame* spriteFrame = frameCache->getSpriteFrameByName(frameName.asString()); @@ -170,7 +170,7 @@ void AnimationCache::parseVersion2(const ValueMap& animations) // Array of AnimationFrames Vector array(static_cast(frameArray.size())); - for (auto& obj : frameArray) + for (auto&& obj : frameArray) { ValueMap& entry = obj.asValueMap(); std::string spriteFrameName = entry["spriteframe"].asString(); diff --git a/core/2d/CCAutoPolygon.cpp b/core/2d/CCAutoPolygon.cpp index 085dc6d17b..a9c65ee1cc 100644 --- a/core/2d/CCAutoPolygon.cpp +++ b/core/2d/CCAutoPolygon.cpp @@ -628,7 +628,7 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector& po } } } - for (auto j : p2points) + for (auto&& j : p2points) { delete j; }; diff --git a/core/2d/CCCameraBackgroundBrush.cpp b/core/2d/CCCameraBackgroundBrush.cpp index 745941b700..a8df5f20e2 100644 --- a/core/2d/CCCameraBackgroundBrush.cpp +++ b/core/2d/CCCameraBackgroundBrush.cpp @@ -254,7 +254,7 @@ void CameraBackgroundColorBrush::drawBackground(Camera* camera) void CameraBackgroundColorBrush::setColor(const Color4F& color) { - for (auto& vert : _vertices) + for (auto&& vert : _vertices) { vert.colors = Color4B(color); } diff --git a/core/2d/CCClippingNode.cpp b/core/2d/CCClippingNode.cpp index 9feabc2976..fbc190605b 100644 --- a/core/2d/CCClippingNode.cpp +++ b/core/2d/CCClippingNode.cpp @@ -329,7 +329,7 @@ void ClippingNode::setProgramStateRecursively(Node* node, backend::ProgramState* void ClippingNode::restoreAllProgramStates() { - for (auto item : _originalStencilProgramState) + for (auto&& item : _originalStencilProgramState) { auto node = item.first; auto programState = item.second; diff --git a/core/2d/CCComponentContainer.cpp b/core/2d/CCComponentContainer.cpp index ee61eac8c2..bb66825f62 100644 --- a/core/2d/CCComponentContainer.cpp +++ b/core/2d/CCComponentContainer.cpp @@ -100,7 +100,7 @@ void ComponentContainer::removeAll() { if (!_componentMap.empty()) { - for (auto& iter : _componentMap) + for (auto&& iter : _componentMap) { iter.second->onRemove(); iter.second->setOwner(nullptr); @@ -117,7 +117,7 @@ void ComponentContainer::visit(float delta) if (!_componentMap.empty()) { AX_SAFE_RETAIN(_owner); - for (auto& iter : _componentMap) + for (auto&& iter : _componentMap) { iter.second->update(delta); } @@ -127,7 +127,7 @@ void ComponentContainer::visit(float delta) void ComponentContainer::onEnter() { - for (auto& iter : _componentMap) + for (auto&& iter : _componentMap) { iter.second->onEnter(); } @@ -135,7 +135,7 @@ void ComponentContainer::onEnter() void ComponentContainer::onExit() { - for (auto& iter : _componentMap) + for (auto&& iter : _componentMap) { iter.second->onExit(); } diff --git a/core/2d/CCFastTMXLayer.cpp b/core/2d/CCFastTMXLayer.cpp index 2cd59291b1..d3eedd87a6 100644 --- a/core/2d/CCFastTMXLayer.cpp +++ b/core/2d/CCFastTMXLayer.cpp @@ -121,7 +121,7 @@ FastTMXLayer::~FastTMXLayer() AX_SAFE_RELEASE(_vertexBuffer); AX_SAFE_RELEASE(_indexBuffer); - for (auto& e : _customCommands) + for (auto&& e : _customCommands) { AX_SAFE_RELEASE(e.second->getPipelineDescriptor().programState); delete e.second; @@ -633,7 +633,7 @@ void FastTMXLayer::updateTotalQuads() } int offset = 0; - for (auto& vertexZOffset : _indicesVertexZOffsets) + for (auto&& vertexZOffset : _indicesVertexZOffsets) { std::swap(offset, vertexZOffset.second); offset += vertexZOffset.second; @@ -976,7 +976,7 @@ TMXTileAnimManager::TMXTileAnimManager(FastTMXLayer* layer) _layer = layer; for (const auto& p : *_layer->getAnimTileCoord()) { - for (auto tilePos : p.second) + for (auto&& tilePos : p.second) { _tasks.pushBack(TMXTileAnimTask::create(_layer, _layer->getTileSet()->_animationInfo.at(p.first), tilePos)); } @@ -995,7 +995,7 @@ void TMXTileAnimManager::startAll() if (_started || _tasks.empty()) return; _started = true; - for (auto& task : _tasks) + for (auto&& task : _tasks) { task->start(); } @@ -1006,7 +1006,7 @@ void TMXTileAnimManager::stopAll() if (!_started) return; _started = false; - for (auto& task : _tasks) + for (auto&& task : _tasks) { task->stop(); } diff --git a/core/2d/CCFastTMXTiledMap.cpp b/core/2d/CCFastTMXTiledMap.cpp index e9894f1ee2..1021de93a3 100644 --- a/core/2d/CCFastTMXTiledMap.cpp +++ b/core/2d/CCFastTMXTiledMap.cpp @@ -198,7 +198,7 @@ FastTMXLayer* FastTMXTiledMap::getLayer(std::string_view layerName) const { AXASSERT(!layerName.empty(), "Invalid layer name!"); - for (auto& child : _children) + for (auto&& child : _children) { FastTMXLayer* layer = dynamic_cast(child); if (layer) @@ -258,7 +258,7 @@ std::string FastTMXTiledMap::getDescription() const void FastTMXTiledMap::setTileAnimEnabled(bool enabled) { - for (auto& child : _children) + for (auto&& child : _children) { FastTMXLayer* layer = dynamic_cast(child); if (layer) diff --git a/core/2d/CCFontAtlas.cpp b/core/2d/CCFontAtlas.cpp index 753f8ad131..523eab25bc 100644 --- a/core/2d/CCFontAtlas.cpp +++ b/core/2d/CCFontAtlas.cpp @@ -139,7 +139,7 @@ void FontAtlas::reset() void FontAtlas::releaseTextures() { - for (auto& item : _atlasTextures) + for (auto&& item : _atlasTextures) { item.second->release(); } @@ -203,7 +203,7 @@ void FontAtlas::findNewCharacters(const std::u32string& u32Text, std::unordered_ } else { - for (auto charCode : u32Text) + for (auto&& charCode : u32Text) if (_letterDefinitions.find(charCode) == _letterDefinitions.end()) charset.insert(charCode); } @@ -239,7 +239,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text) int startY = (int)_currentPageOrigY; - for (auto charCode : charCodeSet) + for (auto&& charCode : charCodeSet) { auto bitmap = _fontFreeType->getGlyphBitmap(charCode, bitmapWidth, bitmapHeight, tempRect, tempDef.xAdvance); if (bitmap && bitmapWidth > 0 && bitmapHeight > 0) diff --git a/core/2d/CCFontAtlasCache.cpp b/core/2d/CCFontAtlasCache.cpp index bdbf72639d..a5382aa11e 100644 --- a/core/2d/CCFontAtlasCache.cpp +++ b/core/2d/CCFontAtlasCache.cpp @@ -244,7 +244,7 @@ bool FontAtlasCache::releaseFontAtlas(FontAtlas* atlas) { if (atlas->getReferenceCount() == 1) { - for (auto& item : _atlasMap) + for (auto&& item : _atlasMap) { if (item.second == atlas) { diff --git a/core/2d/CCLabel.cpp b/core/2d/CCLabel.cpp index 3768bc4ef9..3a601f3333 100644 --- a/core/2d/CCLabel.cpp +++ b/core/2d/CCLabel.cpp @@ -699,7 +699,7 @@ bool Label::setProgramState(backend::ProgramState* programState, bool needsRetai if (Node::setProgramState(programState, needsRetain)) { updateUniformLocations(); - for (auto& batch : _batchCommands) + for (auto&& batch : _batchCommands) { updateBatchCommand(batch); } @@ -768,7 +768,7 @@ void Label::updateShaderProgram() updateUniformLocations(); - for (auto& batch : _batchCommands) + for (auto&& batch : _batchCommands) { updateBatchCommand(batch); } @@ -1983,7 +1983,7 @@ void Label::draw(Renderer* renderer, const Mat4& transform, uint32_t flags) continue; auto& batch = _batchCommands[i++]; - for (auto command : batch.getCommandArray()) + for (auto&& command : batch.getCommandArray()) { auto* programState = command->getPipelineDescriptor().programState; Vec4 textColor(_textColorF.r, _textColorF.g, _textColorF.b, _textColorF.a); @@ -2003,9 +2003,9 @@ void Label::draw(Renderer* renderer, const Mat4& transform, uint32_t flags) void Label::updateBlendState() { setOpacityModifyRGB(_blendFunc != BlendFunc::ALPHA_NON_PREMULTIPLIED); - for (auto& batch : _batchCommands) + for (auto&& batch : _batchCommands) { - for (auto command : batch.getCommandArray()) + for (auto&& command : batch.getCommandArray()) { auto& blendDescriptor = command->getPipelineDescriptor().blendDescriptor; updateBlend(blendDescriptor, _blendFunc); diff --git a/core/2d/CCLabelTextFormatter.cpp b/core/2d/CCLabelTextFormatter.cpp index 5652f741d2..c7deaff6d5 100644 --- a/core/2d/CCLabelTextFormatter.cpp +++ b/core/2d/CCLabelTextFormatter.cpp @@ -42,13 +42,13 @@ void Label::computeAlignmentOffset() _linesOffsetX.assign(_numberOfLines, 0); break; case axis::TextHAlignment::CENTER: - for (auto lineWidth : _linesWidth) + for (auto&& lineWidth : _linesWidth) { _linesOffsetX.push_back((_contentSize.width - lineWidth) / 2.f); } break; case axis::TextHAlignment::RIGHT: - for (auto lineWidth : _linesWidth) + for (auto&& lineWidth : _linesWidth) { _linesOffsetX.push_back(_contentSize.width - lineWidth); } diff --git a/core/2d/CCMenu.cpp b/core/2d/CCMenu.cpp index 06511422ff..3fbed0f4ae 100644 --- a/core/2d/CCMenu.cpp +++ b/core/2d/CCMenu.cpp @@ -128,7 +128,7 @@ bool Menu::initWithArray(const Vector& arrayOfItems) int z = 0; - for (auto& item : arrayOfItems) + for (auto&& item : arrayOfItems) { this->addChild(item, z); z++; diff --git a/core/2d/CCNode.cpp b/core/2d/CCNode.cpp index e52045abd3..ef0992932c 100644 --- a/core/2d/CCNode.cpp +++ b/core/2d/CCNode.cpp @@ -171,7 +171,7 @@ Node::~Node() // `AX_SAFE_RELEASE_NULL(_actionManager)`. AX_SAFE_RELEASE_NULL(_userObject); - for (auto& child : _children) + for (auto&& child : _children) { child->_parent = nullptr; } diff --git a/core/2d/CCParticleSystem.cpp b/core/2d/CCParticleSystem.cpp index 404892db51..d567f9727c 100644 --- a/core/2d/CCParticleSystem.cpp +++ b/core/2d/CCParticleSystem.cpp @@ -1366,7 +1366,7 @@ void ParticleSystem::resetAnimationDescriptors() void ParticleSystem::setMultiAnimationRandom() { _randomAnimations.clear(); - for (auto& a : _animations) + for (auto&& a : _animations) _randomAnimations.push_back(a.first); } diff --git a/core/2d/CCPlistSpriteSheetLoader.cpp b/core/2d/CCPlistSpriteSheetLoader.cpp index a3c848e7c8..9e22185d09 100644 --- a/core/2d/CCPlistSpriteSheetLoader.cpp +++ b/core/2d/CCPlistSpriteSheetLoader.cpp @@ -196,7 +196,7 @@ void PlistSpriteSheetLoader::addSpriteFramesWithDictionary(ValueMap& dictionary, auto textureFileName = Director::getInstance()->getTextureCache()->getTextureFilePath(texture); Image* image = nullptr; NinePatchImageParser parser; - for (auto& iter : framesDict) + for (auto&& iter : framesDict) { auto& frameDict = iter.second.asValueMap(); auto spriteFrameName = iter.first; @@ -394,7 +394,7 @@ void PlistSpriteSheetLoader::reloadSpriteFramesWithDictionary(ValueMap& dict, spriteSheet->format = getFormat(); spriteSheet->path = plist; - for (auto& iter : framesDict) + for (auto&& iter : framesDict) { const ValueMap& frameDict = iter.second.asValueMap(); std::string_view spriteFrameName = iter.first; diff --git a/core/2d/CCProtectedNode.cpp b/core/2d/CCProtectedNode.cpp index c0a97b63e3..b5ea19ba79 100644 --- a/core/2d/CCProtectedNode.cpp +++ b/core/2d/CCProtectedNode.cpp @@ -120,7 +120,7 @@ Node* ProtectedNode::getProtectedChildByTag(int tag) { AXASSERT(tag != Node::INVALID_TAG, "Invalid tag"); - for (auto& child : _protectedChildren) + for (auto&& child : _protectedChildren) { if (child && child->getTag() == tag) return child; @@ -182,7 +182,7 @@ void ProtectedNode::removeAllProtectedChildren() void ProtectedNode::removeAllProtectedChildrenWithCleanup(bool cleanup) { // not using detachChild improves speed here - for (auto& child : _protectedChildren) + for (auto&& child : _protectedChildren) { // IMPORTANT: // -1st do onExit @@ -361,13 +361,13 @@ void ProtectedNode::updateDisplayedOpacity(uint8_t parentOpacity) if (_cascadeOpacityEnabled) { - for (auto child : _children) + for (auto&& child : _children) { child->updateDisplayedOpacity(_displayedOpacity); } } - for (auto child : _protectedChildren) + for (auto&& child : _protectedChildren) { child->updateDisplayedOpacity(_displayedOpacity); } @@ -395,11 +395,11 @@ void ProtectedNode::updateDisplayedColor(const Color3B& parentColor) void ProtectedNode::disableCascadeColor() { - for (auto child : _children) + for (auto&& child : _children) { child->updateDisplayedColor(Color3B::WHITE); } - for (auto child : _protectedChildren) + for (auto&& child : _protectedChildren) { child->updateDisplayedColor(Color3B::WHITE); } @@ -409,12 +409,12 @@ void ProtectedNode::disableCascadeOpacity() { _displayedOpacity = _realOpacity; - for (auto child : _children) + for (auto&& child : _children) { child->updateDisplayedOpacity(255); } - for (auto child : _protectedChildren) + for (auto&& child : _protectedChildren) { child->updateDisplayedOpacity(255); } @@ -425,7 +425,7 @@ void ProtectedNode::setCameraMask(unsigned short mask, bool applyChildren) Node::setCameraMask(mask, applyChildren); if (applyChildren) { - for (auto& iter : _protectedChildren) + for (auto&& iter : _protectedChildren) { iter->setCameraMask(mask); } @@ -435,7 +435,7 @@ void ProtectedNode::setCameraMask(unsigned short mask, bool applyChildren) void ProtectedNode::setGlobalZOrder(float globalZOrder) { Node::setGlobalZOrder(globalZOrder); - for (auto& child : _protectedChildren) + for (auto&& child : _protectedChildren) child->setGlobalZOrder(globalZOrder); } diff --git a/core/2d/CCSpriteFrameCache.cpp b/core/2d/CCSpriteFrameCache.cpp index ab80c61c24..97d94d75f9 100644 --- a/core/2d/CCSpriteFrameCache.cpp +++ b/core/2d/CCSpriteFrameCache.cpp @@ -151,7 +151,7 @@ void SpriteFrameCache::removeUnusedSpriteFrames() std::vector toRemoveFrames; const auto& frames = getSpriteFrames(); - for (auto& iter : frames) + for (auto&& iter : frames) { auto* spriteFrame = iter.second; if (spriteFrame->getReferenceCount() == 1) @@ -228,7 +228,7 @@ void SpriteFrameCache::removeSpriteFramesFromTexture(Texture2D* texture) { std::vector keysToRemove; - for (auto& iter : getSpriteFrames()) + for (auto&& iter : getSpriteFrames()) { auto key = iter.first; auto* frame = findFrame(key); diff --git a/core/3d/CCAnimate3D.cpp b/core/3d/CCAnimate3D.cpp index 12d3a269dc..7b8e237387 100644 --- a/core/3d/CCAnimate3D.cpp +++ b/core/3d/CCAnimate3D.cpp @@ -411,7 +411,7 @@ void Animate3D::update(float t) } } std::sort(eventInfos.begin(), eventInfos.end(), _playReverse ? cmpEventInfoDes : cmpEventInfoAsc); - for (auto eventInfo : eventInfos) + for (auto&& eventInfo : eventInfos) { Director::getInstance()->getEventDispatcher()->dispatchEvent(_keyFrameEvent[eventInfo->frame]); } @@ -507,7 +507,7 @@ Animate3D::~Animate3D() { removeFromMap(); - for (auto& it : _keyFrameEvent) + for (auto&& it : _keyFrameEvent) { delete it.second; } diff --git a/core/3d/CCAnimation3D.cpp b/core/3d/CCAnimation3D.cpp index a6d15cf3e4..cfdf6944ab 100644 --- a/core/3d/CCAnimation3D.cpp +++ b/core/3d/CCAnimation3D.cpp @@ -220,7 +220,7 @@ void Animation3DCache::addAnimation(std::string_view key, Animation3D* animation void Animation3DCache::removeAllAnimations() { - for (auto itor : _animations) + for (auto&& itor : _animations) { AX_SAFE_RELEASE(itor.second); } diff --git a/core/3d/CCBundle3D.cpp b/core/3d/CCBundle3D.cpp index ab24f34ef2..8fc6345718 100644 --- a/core/3d/CCBundle3D.cpp +++ b/core/3d/CCBundle3D.cpp @@ -230,7 +230,7 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas, auto last = fullPath.rfind('/'); if (last != std::string::npos) dir = fullPath.substr(0, last + 1); - for (auto& material : materials) + for (auto&& material : materials) { NMaterialData materialdata; @@ -249,7 +249,7 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas, // convert mesh i = 0; - for (auto& shape : shapes) + for (auto&& shape : shapes) { auto mesh = shape.mesh; MeshData* meshdata = new MeshData(); @@ -310,7 +310,7 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas, auto node = new NodeData(); node->id = shape.name; - for (auto& submesh : subMeshMap) + for (auto&& submesh : subMeshMap) { auto& storedIndices = meshdata->subMeshIndices.emplace_back(std::move(submesh.second)); meshdata->subMeshAABB.push_back( @@ -490,7 +490,7 @@ bool Bundle3D::loadMeshDatasBinary(MeshDatas& meshdatas) FAILED: { AX_SAFE_DELETE(meshData); - for (auto& meshdata : meshdatas.meshDatas) + for (auto&& meshdata : meshdatas.meshDatas) { delete meshdata; } @@ -2297,7 +2297,7 @@ std::vector Bundle3D::getTrianglesList(std::string_view path) } Bundle3D::destroyBundle(bundle); - for (auto iter : meshs.meshDatas) + for (auto&& iter : meshs.meshDatas) { int preVertexSize = iter->getPerVertexSize() / sizeof(float); for (const auto& indices : iter->subMeshIndices) diff --git a/core/3d/CCBundle3DData.h b/core/3d/CCBundle3DData.h index d7b5996ec0..0c445d4f93 100644 --- a/core/3d/CCBundle3DData.h +++ b/core/3d/CCBundle3DData.h @@ -272,13 +272,13 @@ struct NodeData { id.clear(); transform.setIdentity(); - for (auto& it : children) + for (auto&& it : children) { delete it; } children.clear(); - for (auto& modeldata : modelNodeDatas) + for (auto&& modeldata : modelNodeDatas) { delete modeldata; } @@ -299,12 +299,12 @@ struct NodeDatas void resetData() { - for (auto& it : skeleton) + for (auto&& it : skeleton) { delete it; } skeleton.clear(); - for (auto& it : nodes) + for (auto&& it : nodes) { delete it; } @@ -369,7 +369,7 @@ struct MeshDatas void resetData() { - for (auto& it : meshDatas) + for (auto&& it : meshDatas) { delete it; } diff --git a/core/3d/CCMesh.cpp b/core/3d/CCMesh.cpp index b757ab4924..c7924fa49c 100644 --- a/core/3d/CCMesh.cpp +++ b/core/3d/CCMesh.cpp @@ -122,7 +122,7 @@ Mesh::Mesh() {} Mesh::~Mesh() { - for (auto& tex : _textures) + for (auto&& tex : _textures) { AX_SAFE_RELEASE(tex.second); } @@ -288,7 +288,7 @@ void Mesh::setTexture(Texture2D* tex, NTextureData::Usage usage, bool cacheFileN if (_material) { auto technique = _material->_currentTechnique; - for (auto& pass : technique->_passes) + for (auto&& pass : technique->_passes) { pass->setUniformTexture(0, tex->getBackendTexture()); } @@ -303,7 +303,7 @@ void Mesh::setTexture(Texture2D* tex, NTextureData::Usage usage, bool cacheFileN if (_material) { auto technique = _material->_currentTechnique; - for (auto& pass : technique->_passes) + for (auto&& pass : technique->_passes) { pass->setUniformNormTexture(1, tex->getBackendTexture()); } @@ -339,7 +339,7 @@ void Mesh::setMaterial(Material* material) if (_material) { - for (auto technique : _material->getTechniques()) + for (auto&& technique : _material->getTechniques()) { // allocate MeshCommand vector for technique // allocate MeshCommand for each pass @@ -347,7 +347,7 @@ void Mesh::setMaterial(Material* material) auto& list = _meshCommands[technique->getName()]; int i = 0; - for (auto pass : technique->getPasses()) + for (auto&& pass : technique->getPasses()) { #ifdef AXIS_DEBUG // make it crashed when missing attribute data @@ -370,7 +370,7 @@ void Mesh::setMaterial(Material* material) _meshIndexData->setPrimitiveType(material->getPrimitiveType()); } // Was the texture set before the GLProgramState ? Set it - for (auto& tex : _textures) + for (auto&& tex : _textures) setTexture(tex.second, tex.first); if (_blendDirty) @@ -436,7 +436,7 @@ void Mesh::draw(Renderer* renderer, } auto& commands = _meshCommands[technique->getName()]; - for (auto& command : commands) + for (auto&& command : commands) { command.init(globalZ, transform); command.setSkipBatching(isTransparent); diff --git a/core/3d/CCMeshMaterial.cpp b/core/3d/CCMeshMaterial.cpp index ad6b174d60..1562c9b56b 100644 --- a/core/3d/CCMeshMaterial.cpp +++ b/core/3d/CCMeshMaterial.cpp @@ -183,7 +183,7 @@ void MeshMaterial::releaseBuiltInMaterial() void MeshMaterial::releaseCachedMaterial() { - for (auto& it : _materials) + for (auto&& it : _materials) { if (it.second) it.second->release(); @@ -307,7 +307,7 @@ MeshMaterial* MeshMaterial::createWithProgramState(backend::ProgramState* progra void MeshMaterial::setTexture(Texture2D* tex, NTextureData::Usage usage) { const auto& passes = getTechnique()->getPasses(); - for (auto& pass : passes) + for (auto&& pass : passes) { pass->setUniformTexture(0, tex->getBackendTexture()); } @@ -364,7 +364,7 @@ Texture2D* MeshMaterialCache::getMeshMaterial(std::string_view key) void MeshMaterialCache::removeAllMeshMaterial() { - for (auto& itr : _materials) + for (auto&& itr : _materials) { AX_SAFE_RELEASE_NULL(itr.second); } diff --git a/core/3d/CCMeshRenderer.cpp b/core/3d/CCMeshRenderer.cpp index 84fbf5ef8d..bf1f34bfa7 100644 --- a/core/3d/CCMeshRenderer.cpp +++ b/core/3d/CCMeshRenderer.cpp @@ -185,7 +185,7 @@ void MeshRenderer::afterAsyncLoad(void* param) AABB MeshRenderer::getAABBRecursivelyImp(Node* node) { AABB aabb; - for (auto iter : node->getChildren()) + for (auto&& iter : node->getChildren()) { aabb.merge(getAABBRecursivelyImp(iter)); } @@ -202,7 +202,7 @@ bool MeshRenderer::loadFromCache(std::string_view path) auto meshdata = MeshRendererCache::getInstance()->getMeshRenderData(path); if (meshdata) { - for (auto it : meshdata->meshVertexDatas) + for (auto&& it : meshdata->meshVertexDatas) { _meshVertexDatas.pushBack(it); } @@ -502,14 +502,14 @@ void MeshRenderer::genMaterial(bool useLight) _shaderUsingLight = useLight; std::unordered_map materials; - for (auto meshVertexData : _meshVertexDatas) + for (auto&& meshVertexData : _meshVertexDatas) { auto material = getMeshRendererMaterialForAttribs(meshVertexData, useLight); AXASSERT(material, "material should cannot be null."); materials[meshVertexData] = material; } - for (auto& mesh : _meshes) + for (auto&& mesh : _meshes) { auto material = materials[mesh->getMeshIndexData()->getMeshVertexData()]; // keep original state block if exist @@ -656,7 +656,7 @@ void MeshRenderer::createNode(NodeData* nodedata, Node* root, const MaterialData MeshIndexData* MeshRenderer::getMeshIndexData(std::string_view indexId) const { - for (auto it : _meshVertexDatas) + for (auto&& it : _meshVertexDatas) { auto index = it->getMeshIndexDataById(indexId); if (index) @@ -680,7 +680,7 @@ void MeshRenderer::setTexture(std::string_view texFile) void MeshRenderer::setTexture(Texture2D* texture) { - for (auto mesh : _meshes) + for (auto&& mesh : _meshes) { mesh->setTexture(texture); } @@ -718,7 +718,7 @@ void MeshRenderer::removeAttachNode(std::string_view boneName) void MeshRenderer::removeAllAttachNode() { - for (auto& it : _attachments) + for (auto&& it : _attachments) { removeChild(it.second); } @@ -808,7 +808,7 @@ void MeshRenderer::draw(Renderer* renderer, const Mat4& transform, uint32_t flag } } - for (auto mesh : _meshes) + for (auto&& mesh : _meshes) { mesh->draw(renderer, _globalZOrder, transform, flags, _lightMask, Vec4(color.r, color.g, color.b, color.a), _forceDepthWrite); @@ -819,7 +819,7 @@ bool MeshRenderer::setProgramState(backend::ProgramState* programState, bool nee { if (Node::setProgramState(programState, needsRetain)) { - for (auto state : _meshes) + for (auto&& state : _meshes) { state->setProgramState(programState); } @@ -833,7 +833,7 @@ void MeshRenderer::setBlendFunc(const BlendFunc& blendFunc) if (_blend.src != blendFunc.src || _blend.dst != blendFunc.dst) { _blend = blendFunc; - for (auto mesh : _meshes) + for (auto&& mesh : _meshes) { mesh->setBlendFunc(blendFunc); } @@ -895,7 +895,7 @@ Rect MeshRenderer::getBoundingBox() const void MeshRenderer::setCullFace(CullFaceSide side) { - for (auto& it : _meshes) + for (auto&& it : _meshes) { it->getMaterial()->getStateBlock().setCullFaceSide(side); } @@ -903,7 +903,7 @@ void MeshRenderer::setCullFace(CullFaceSide side) void MeshRenderer::setCullFaceEnabled(bool enable) { - for (auto& it : _meshes) + for (auto&& it : _meshes) { it->getMaterial()->getStateBlock().setCullFace(enable); } @@ -1002,7 +1002,7 @@ void MeshRendererCache::removeMeshRenderData(std::string_view key) void MeshRendererCache::removeAllMeshRenderData() { - for (auto& it : _meshDatas) + for (auto&& it : _meshDatas) { delete it.second; } diff --git a/core/3d/CCMeshSkin.cpp b/core/3d/CCMeshSkin.cpp index 3fb45fefd3..73ef720727 100644 --- a/core/3d/CCMeshSkin.cpp +++ b/core/3d/CCMeshSkin.cpp @@ -103,7 +103,7 @@ Vec4* MeshSkin::getMatrixPalette() _matrixPalette.resize(_skinBones.size() * PALETTE_ROWS); int i = 0, paletteIndex = 0; static Mat4 t; - for (auto it : _skinBones) + for (auto&& it : _skinBones) { Mat4::multiply(it->getWorldMat(), _invBindPoses[i++], &t); _matrixPalette[paletteIndex++].set(t.m[0], t.m[4], t.m[8], t.m[12]); diff --git a/core/3d/CCMeshVertexIndexData.cpp b/core/3d/CCMeshVertexIndexData.cpp index 00188bd664..b341f722f2 100644 --- a/core/3d/CCMeshVertexIndexData.cpp +++ b/core/3d/CCMeshVertexIndexData.cpp @@ -162,7 +162,7 @@ MeshVertexData* MeshVertexData::create(const MeshData& meshdata, CustomCommand:: MeshIndexData* MeshVertexData::getMeshIndexDataById(std::string_view id) const { - for (auto it : _indices) + for (auto&& it : _indices) { if (it->getId() == id) return it; diff --git a/core/3d/CCSkeleton3D.cpp b/core/3d/CCSkeleton3D.cpp index 2e36102cd2..4931cbd49f 100644 --- a/core/3d/CCSkeleton3D.cpp +++ b/core/3d/CCSkeleton3D.cpp @@ -51,7 +51,7 @@ void Bone3D::resetPose() { _local = _oriPose; - for (auto it : _children) + for (auto&& it : _children) { it->resetPose(); } @@ -60,7 +60,7 @@ void Bone3D::resetPose() void Bone3D::setWorldMatDirty(bool dirty) { _worldDirty = dirty; - for (auto it : _children) + for (auto&& it : _children) { it->setWorldMatDirty(dirty); } @@ -70,7 +70,7 @@ void Bone3D::setWorldMatDirty(bool dirty) void Bone3D::updateWorldMat() { getWorldMat(); - for (auto itor : _children) + for (auto&& itor : _children) { itor->updateWorldMat(); } @@ -96,7 +96,7 @@ const Mat4& Bone3D::getWorldMat() void Bone3D::setAnimationValue(float* trans, float* rot, float* scale, void* tag, float weight) { - for (auto& it : _blendStates) + for (auto&& it : _blendStates) { if (it.tag == tag) { @@ -127,7 +127,7 @@ void Bone3D::setAnimationValue(float* trans, float* rot, float* scale, void* tag void Bone3D::clearBoneBlendState() { _blendStates.clear(); - for (auto it : _children) + for (auto&& it : _children) { it->clearBoneBlendState(); } @@ -282,7 +282,7 @@ Bone3D* Skeleton3D::getBoneByIndex(unsigned int index) const Bone3D* Skeleton3D::getBoneByName(std::string_view id) const { // search from bones - for (auto it : _bones) + for (auto&& it : _bones) { if (it->getName() == id) return it; diff --git a/core/3d/CCTerrain.cpp b/core/3d/CCTerrain.cpp index 4106bac62a..de0b7f1340 100644 --- a/core/3d/CCTerrain.cpp +++ b/core/3d/CCTerrain.cpp @@ -438,7 +438,7 @@ void Terrain::calculateNormal() _vertices[Index2]._normal += Normal; } - for (auto& vertex : _vertices) + for (auto&& vertex : _vertices) { vertex._normal.normalize(); } @@ -1565,7 +1565,7 @@ Terrain::QuadTree::QuadTree(int x, int y, int w, int h, Terrain* terrain) _localAABB = _chunk->_aabb; _chunk->_parent = this; - for (auto& triangle : _chunk->_trianglesList) + for (auto&& triangle : _chunk->_trianglesList) { triangle.transform(_terrain->getNodeToWorldTransform()); } diff --git a/core/audio/AudioEngineImpl.cpp b/core/audio/AudioEngineImpl.cpp index 4834d22f6c..8a996332e8 100644 --- a/core/audio/AudioEngineImpl.cpp +++ b/core/audio/AudioEngineImpl.cpp @@ -835,7 +835,7 @@ void AudioEngineImpl::_updatePlayers(bool forStop) { if (!_finishCallbacks.empty()) { - for (auto& finishCallback : _finishCallbacks) + for (auto&& finishCallback : _finishCallbacks) finishCallback(); _finishCallbacks.clear(); } @@ -864,7 +864,7 @@ void AudioEngineImpl::uncache(std::string_view filePath) void AudioEngineImpl::uncacheAll() { // prevent player hold invalid AudioCache* pointer, since all audio caches purged - for (auto& player : _audioPlayers) + for (auto&& player : _audioPlayers) player.second->setCache(nullptr); _audioCaches.clear(); diff --git a/core/base/CCConsole.cpp b/core/base/CCConsole.cpp index 996603cd6a..f2b4f6fd58 100644 --- a/core/base/CCConsole.cpp +++ b/core/base/CCConsole.cpp @@ -483,7 +483,7 @@ Console::~Console() { stop(); - for (auto& e : _commands) + for (auto&& e : _commands) delete e.second; } @@ -812,7 +812,7 @@ void Console::loop() { for (const auto& str : _DebugStrings) { - for (auto fd : _fds) + for (auto&& fd : _fds) { Console::Utility::sendToConsole(fd, str.c_str(), str.length()); } @@ -959,7 +959,7 @@ bool Console::parseCommand(socket_native_type fd) auto commands = Console::Utility::split(cmdLine, _commandSeparator); try { - for (auto command : commands) + for (auto&& command : commands) { performCommand(fd, Console::Utility::trim(command)); } @@ -1623,7 +1623,7 @@ void Console::printFileUtils(socket_native_type fd) void Console::sendHelp(socket_native_type fd, const hlookup::string_map& commands, const char* msg) { Console::Utility::sendToConsole(fd, msg, strlen(msg)); - for (auto& it : commands) + for (auto&& it : commands) { auto command = it.second; if (command->getHelp().empty()) diff --git a/core/base/CCController-linux-win32.cpp b/core/base/CCController-linux-win32.cpp index ef47c412b5..e49400c453 100644 --- a/core/base/CCController-linux-win32.cpp +++ b/core/base/CCController-linux-win32.cpp @@ -4182,7 +4182,7 @@ public: { // If there are any controllers connected that were not deleted at the end of execution, delete them. // This wil prevent any memory leaks showing up in valgrind - for (auto& controller : Controller::s_allController) + for (auto&& controller : Controller::s_allController) { delete controller; } @@ -4422,7 +4422,7 @@ void Controller::stopDiscoveryController() glfwSetJoystickCallback(nullptr); // Also remove all the connected controllers: - for (auto& controller : Controller::s_allController) + for (auto&& controller : Controller::s_allController) { delete controller; } diff --git a/core/base/CCController.cpp b/core/base/CCController.cpp index aeaadb11b8..741cf4ef5b 100644 --- a/core/base/CCController.cpp +++ b/core/base/CCController.cpp @@ -40,7 +40,7 @@ std::vector Controller::s_allController; Controller* Controller::getControllerByTag(int tag) { - for (auto controller : Controller::s_allController) + for (auto&& controller : Controller::s_allController) { if (controller->_controllerTag == tag) { @@ -52,7 +52,7 @@ Controller* Controller::getControllerByTag(int tag) Controller* Controller::getControllerByDeviceId(int deviceId) { - for (auto controller : Controller::s_allController) + for (auto&& controller : Controller::s_allController) { if (controller->_deviceId == deviceId) { diff --git a/core/base/CCEventDispatcher.cpp b/core/base/CCEventDispatcher.cpp index 4a5de99334..7f528c580b 100644 --- a/core/base/CCEventDispatcher.cpp +++ b/core/base/CCEventDispatcher.cpp @@ -285,13 +285,13 @@ void EventDispatcher::pauseEventListenersForTarget(Node* target, bool recursive if (listenerIter != _nodeListenersMap.end()) { auto listeners = listenerIter->second; - for (auto& l : *listeners) + for (auto&& l : *listeners) { l->setPaused(true); } } - for (auto& listener : _toAddedListeners) + for (auto&& listener : _toAddedListeners) { if (listener->getAssociatedNode() == target) { @@ -315,13 +315,13 @@ void EventDispatcher::resumeEventListenersForTarget(Node* target, bool recursive if (listenerIter != _nodeListenersMap.end()) { auto listeners = listenerIter->second; - for (auto& l : *listeners) + for (auto&& l : *listeners) { l->setPaused(false); } } - for (auto& listener : _toAddedListeners) + for (auto&& listener : _toAddedListeners) { if (listener->getAssociatedNode() == target) { @@ -353,7 +353,7 @@ void EventDispatcher::removeEventListenersForTarget(Node* target, bool recursive { auto listeners = listenerIter->second; auto listenersCopy = *listeners; - for (auto& l : listenersCopy) + for (auto&& l : listenersCopy) { removeEventListener(l); } @@ -704,7 +704,7 @@ void EventDispatcher::setPriority(EventListener* listener, int fixedPriority) if (listener == nullptr) return; - for (auto& iter : _listenerMap) + for (auto&& iter : _listenerMap) { auto fixedPriorityListeners = iter.second->getFixedPriorityListeners(); if (fixedPriorityListeners) @@ -759,7 +759,7 @@ void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners, if (!shouldStopPropagation) { // priority == 0, scene graph priority - for (auto& l : *sceneGraphPriorityListeners) + for (auto&& l : *sceneGraphPriorityListeners) { if (l->isEnabled() && !l->isPaused() && l->isRegistered() && onEvent(l)) { @@ -827,7 +827,7 @@ void EventDispatcher::dispatchTouchEventToListeners(EventListenerVector* listene // first, get all enabled, unPaused and registered listeners std::vector sceneListeners; - for (auto& l : *sceneGraphPriorityListeners) + for (auto&& l : *sceneGraphPriorityListeners) { if (l->isEnabled() && !l->isPaused() && l->isRegistered()) { @@ -848,7 +848,7 @@ void EventDispatcher::dispatchTouchEventToListeners(EventListenerVector* listene Camera::_visitingCamera = camera; auto cameraFlag = (unsigned short)camera->getCameraFlag(); - for (auto& l : sceneListeners) + for (auto&& l : sceneListeners) { if (nullptr == l->getAssociatedNode() || 0 == (l->getAssociatedNode()->getCameraMask() & cameraFlag)) @@ -968,7 +968,7 @@ void EventDispatcher::dispatchTouchEvent(EventTouch* event) { auto mutableTouchesIter = mutableTouches.begin(); - for (auto& touches : originalTouches) + for (auto&& touches : originalTouches) { bool isSwallowed = false; @@ -1235,7 +1235,7 @@ void EventDispatcher::updateListeners(Event* event) if (!_toAddedListeners.empty()) { - for (auto& listener : _toAddedListeners) + for (auto&& listener : _toAddedListeners) { forceAddEventListener(listener); } @@ -1252,12 +1252,12 @@ void EventDispatcher::updateDirtyFlagForSceneGraph() { if (!_dirtyNodes.empty()) { - for (auto& node : _dirtyNodes) + for (auto&& node : _dirtyNodes) { auto iter = _nodeListenersMap.find(node); if (iter != _nodeListenersMap.end()) { - for (auto& l : *iter->second) + for (auto&& l : *iter->second) { setDirty(l->getListenerID(), DirtyFlag::SCENE_GRAPH_PRIORITY); } @@ -1328,7 +1328,7 @@ void EventDispatcher::sortEventListenersOfSceneGraphPriority(std::string_view li #if DUMP_LISTENER_ITEM_PRIORITY_INFO log("-----------------------------------"); - for (auto& l : *sceneGraphListeners) + for (auto&& l : *sceneGraphListeners) { log("listener priority: node ([%s]%p), priority (%d)", typeid(*l->_node).name(), l->_node, _nodePriorityMap[l->_node]); @@ -1355,7 +1355,7 @@ void EventDispatcher::sortEventListenersOfFixedPriority(std::string_view listene // FIXME: Should use binary search int index = 0; - for (auto& listener : *fixedListeners) + for (auto&& listener : *fixedListeners) { if (listener->getFixedPriority() >= 0) break; @@ -1366,7 +1366,7 @@ void EventDispatcher::sortEventListenersOfFixedPriority(std::string_view listene #if DUMP_LISTENER_ITEM_PRIORITY_INFO log("-----------------------------------"); - for (auto& l : *fixedListeners) + for (auto&& l : *fixedListeners) { log("listener priority: node (%p), fixed (%d)", l->_node, l->_fixedPriority); } @@ -1554,7 +1554,7 @@ void EventDispatcher::setDirty(std::string_view listenerID, DirtyFlag flag) void EventDispatcher::cleanToRemovedListeners() { - for (auto& l : _toRemovedListeners) + for (auto&& l : _toRemovedListeners) { auto listenersIter = _listenerMap.find(l->getListenerID()); if (listenersIter == _listenerMap.end()) diff --git a/core/base/CCMap.h b/core/base/CCMap.h index 690d6c45a1..b061f9f38d 100644 --- a/core/base/CCMap.h +++ b/core/base/CCMap.h @@ -430,7 +430,7 @@ protected: /** Retains all the objects in the map */ void addRefForAllObjects() { - for (auto& iter : _data) + for (auto&& iter : _data) { iter.second->retain(); } diff --git a/core/base/CCProfiling.cpp b/core/base/CCProfiling.cpp index 6e43641922..552ea8f356 100644 --- a/core/base/CCProfiling.cpp +++ b/core/base/CCProfiling.cpp @@ -78,7 +78,7 @@ Profiler::~Profiler() {} void Profiler::displayTimers() { - for (auto& iter : _activeTimers) + for (auto&& iter : _activeTimers) { ProfilingTimer* timer = iter.second; log("%s", timer->getDescription().c_str()); diff --git a/core/base/CCProperties.cpp b/core/base/CCProperties.cpp index 5dfa96edd5..f54fcef390 100644 --- a/core/base/CCProperties.cpp +++ b/core/base/CCProperties.cpp @@ -833,7 +833,7 @@ bool Properties::setString(const char* name, const char* value) { if (name) { - for (auto& itr : _properties) + for (auto&& itr : _properties) { if (itr.name == name) { diff --git a/core/base/CCScheduler.cpp b/core/base/CCScheduler.cpp index 9ae3d570c4..ae68e416e2 100644 --- a/core/base/CCScheduler.cpp +++ b/core/base/CCScheduler.cpp @@ -908,7 +908,7 @@ void Scheduler::update(float dt) } // delete all updates that are removed in update - for (auto& e : _updateDeleteVector) + for (auto&& e : _updateDeleteVector) delete e; _updateDeleteVector.clear(); diff --git a/core/base/CCUserDefault.cpp b/core/base/CCUserDefault.cpp index 8c9b97f697..e008f4c592 100644 --- a/core/base/CCUserDefault.cpp +++ b/core/base/CCUserDefault.cpp @@ -445,7 +445,7 @@ void UserDefault::lazyInit() pugi::xml_parse_result ret = doc.load_buffer_inplace(data.getBytes(), data.getSize()); if (ret) { - for (auto& elem : doc.document_element()) + for (auto&& elem : doc.document_element()) updateValueForKey(elem.name(), elem.text().as_string()); } else @@ -466,7 +466,7 @@ void UserDefault::flush() { yasio::obstream obs; obs.write(static_cast(this->_values.size())); - for (auto& item : this->_values) + for (auto&& item : this->_values) { if (_encryptEnabled) { @@ -506,7 +506,7 @@ void UserDefault::flush() doc.load_string(R"( )"); auto r = doc.document_element(); - for (auto& kv : _values) + for (auto&& kv : _values) r.append_child(kv.first.c_str()).append_child(pugi::xml_node_type::node_pcdata).set_value(kv.second.c_str()); std::stringstream ss; diff --git a/core/base/CCValue.cpp b/core/base/CCValue.cpp index 3326394444..6b32cfdf3a 100644 --- a/core/base/CCValue.cpp +++ b/core/base/CCValue.cpp @@ -857,7 +857,7 @@ static std::string visitMap(const T& v, int depth) ret << getTabs(depth) << "{\n"; - for (auto& iter : v) + for (auto&& iter : v) { ret << getTabs(depth + 1) << iter.first << ": "; ret << visit(iter.second, depth + 1); diff --git a/core/base/CCVector.h b/core/base/CCVector.h index 4902db18aa..5f6e740f6f 100644 --- a/core/base/CCVector.h +++ b/core/base/CCVector.h @@ -127,7 +127,7 @@ public: /** Constructor with initializer list. */ Vector(std::initializer_list list) { - for (auto& element : list) + for (auto&& element : list) { pushBack(element); } @@ -424,7 +424,7 @@ public: */ void clear() { - for (auto& it : _data) + for (auto&& it : _data) { it->release(); } diff --git a/core/base/ZipUtils.cpp b/core/base/ZipUtils.cpp index 46a9daafd8..f3131b2044 100644 --- a/core/base/ZipUtils.cpp +++ b/core/base/ZipUtils.cpp @@ -768,7 +768,7 @@ std::vector ZipFile::listFiles(std::string_view pathname) const // ensure pathname ends with `/` as a directory std::string ensureDir; std::string_view dirname = pathname[pathname.length() - 1] == '/' ? pathname : (ensureDir.append(pathname) += '/'); - for (auto& item : _data->fileList) + for (auto&& item : _data->fileList) { std::string_view filename = item.first; if (cxx20::starts_with(filename, cxx17::string_view{dirname})) diff --git a/core/base/astc.cpp b/core/base/astc.cpp index 41a773d6e2..976a4eeb20 100644 --- a/core/base/astc.cpp +++ b/core/base/astc.cpp @@ -90,7 +90,7 @@ public: _task_queue_cv.notify_all(); _task_queue_mtx.unlock(); - for (auto& t : _threads) + for (auto&& t : _threads) { if (t.joinable()) t.join(); diff --git a/core/base/ccUtils.cpp b/core/base/ccUtils.cpp index cecc77290b..bbc2ef3de2 100644 --- a/core/base/ccUtils.cpp +++ b/core/base/ccUtils.cpp @@ -255,7 +255,7 @@ Rect getCascadeBoundingBox(Node* node) // check all children bounding box, get maximize box Node* child = nullptr; bool merge = false; - for (auto object : node->getChildren()) + for (auto&& object : node->getChildren()) { child = dynamic_cast(object); if (!child->isVisible()) @@ -359,7 +359,7 @@ Node* findChild(Node* levelRoot, std::string_view name) return target; // Find recursively - for (auto& child : levelRoot->getChildren()) + for (auto&& child : levelRoot->getChildren()) { target = findChild(child, name); if (target != nullptr) @@ -379,7 +379,7 @@ Node* findChild(Node* levelRoot, int tag) return target; // Find recursively - for (auto& child : levelRoot->getChildren()) + for (auto&& child : levelRoot->getChildren()) { target = findChild(child, tag); if (target != nullptr) diff --git a/core/navmesh/CCNavMesh.cpp b/core/navmesh/CCNavMesh.cpp index 49f1fd72e7..12fae68908 100644 --- a/core/navmesh/CCNavMesh.cpp +++ b/core/navmesh/CCNavMesh.cpp @@ -125,13 +125,13 @@ NavMesh::~NavMesh() AX_SAFE_DELETE(_meshProcess); AX_SAFE_DELETE(_geomData); - for (auto iter : _agentList) + for (auto&& iter : _agentList) { AX_SAFE_RELEASE(iter); } _agentList.clear(); - for (auto iter : _obstacleList) + for (auto&& iter : _obstacleList) { AX_SAFE_RELEASE(iter); } @@ -320,7 +320,7 @@ void axis::NavMesh::drawOffMeshConnections() void axis::NavMesh::drawObstacles() { // Draw obstacles - for (auto iter : _obstacleList) + for (auto&& iter : _obstacleList) { if (iter) { @@ -347,7 +347,7 @@ void axis::NavMesh::drawObstacles() void axis::NavMesh::drawAgents() { - for (auto iter : _agentList) + for (auto&& iter : _agentList) { if (iter) { @@ -375,7 +375,7 @@ void axis::NavMesh::drawAgents() } // Velocity stuff. - for (auto iter : _agentList) + for (auto&& iter : _agentList) { if (iter) { @@ -478,13 +478,13 @@ void NavMesh::debugDraw(Renderer* renderer) void NavMesh::update(float dt) { - for (auto iter : _agentList) + for (auto&& iter : _agentList) { if (iter) iter->preUpdate(dt); } - for (auto iter : _obstacleList) + for (auto&& iter : _obstacleList) { if (iter) iter->preUpdate(dt); @@ -496,13 +496,13 @@ void NavMesh::update(float dt) if (_tileCache) _tileCache->update(dt, _navMesh); - for (auto iter : _agentList) + for (auto&& iter : _agentList) { if (iter) iter->postUpdate(dt); } - for (auto iter : _obstacleList) + for (auto&& iter : _obstacleList) { if (iter) iter->postUpdate(dt); diff --git a/core/navmesh/CCNavMeshDebugDraw.cpp b/core/navmesh/CCNavMeshDebugDraw.cpp index e9e59703cc..60dd6e9e3e 100644 --- a/core/navmesh/CCNavMeshDebugDraw.cpp +++ b/core/navmesh/CCNavMeshDebugDraw.cpp @@ -94,7 +94,7 @@ void NavMeshDebugDraw::vertex(const float* pos, unsigned int color) NavMeshDebugDraw::~NavMeshDebugDraw() { - for (auto iter : _primitiveList) + for (auto&& iter : _primitiveList) { delete iter; } @@ -191,7 +191,7 @@ void NavMeshDebugDraw::draw(Renderer* renderer) { _commands.resize(_primitiveList.size()); } - for (auto& iter : _primitiveList) + for (auto&& iter : _primitiveList) { if (iter->type == backend::PrimitiveType::POINT) continue; @@ -255,7 +255,7 @@ void NavMeshDebugDraw::onBeforeEachCommand(bool enableDepthWrite) void NavMeshDebugDraw::clear() { _vertices.clear(); - for (auto iter : _primitiveList) + for (auto&& iter : _primitiveList) { delete iter; } diff --git a/core/network/CCDownloader-curl.cpp b/core/network/CCDownloader-curl.cpp index 2e2381aa56..c347388f68 100644 --- a/core/network/CCDownloader-curl.cpp +++ b/core/network/CCDownloader-curl.cpp @@ -414,7 +414,7 @@ public: if (!_processSet.empty()) { std::lock_guard lock(_processMutex); - for (auto& task : _processSet) + for (auto&& task : _processSet) task->cancel(); _processSet.clear(); } @@ -434,7 +434,7 @@ public: { std::lock_guard lock(_processMutex); outList.reserve(_processSet.size()); - for (auto& task : _processSet) + for (auto&& task : _processSet) { if (!task->background) outList.push_back(task); @@ -984,7 +984,7 @@ void DownloaderCURL::_onUpdate(float) // update processing tasks _impl->getProcessTasks(tasks); - for (auto& task : tasks) + for (auto&& task : tasks) { DownloadTaskCURL& coTask = static_cast(*task->_coTask); std::lock_guard lock(coTask._mutex); @@ -1007,7 +1007,7 @@ void DownloaderCURL::_onUpdate(float) _scheduler->pauseTarget(this); } - for (auto& task : tasks) + for (auto&& task : tasks) { _onDownloadFinished(*task); } diff --git a/core/network/HttpClient.cpp b/core/network/HttpClient.cpp index c8d0f3d6db..cc9f6fc504 100644 --- a/core/network/HttpClient.cpp +++ b/core/network/HttpClient.cpp @@ -320,7 +320,7 @@ void HttpClient::handleNetworkEvent(yasio::io_event* event) if (!headers.empty()) { using namespace cxx17; // for string_view literal - for (auto& header : headers) + for (auto&& header : headers) { obs.write_bytes(header); obs.write_bytes("\r\n"); diff --git a/core/network/HttpCookie.cpp b/core/network/HttpCookie.cpp index c5fe3e36eb..3ea4e8cc8e 100644 --- a/core/network/HttpCookie.cpp +++ b/core/network/HttpCookie.cpp @@ -103,7 +103,7 @@ const std::vector* HttpCookie::getCookies() const const CookieInfo* HttpCookie::getMatchCookie(const Uri& uri) const { - for (auto& cookie : _cookies) + for (auto&& cookie : _cookies) { if (cxx20::ends_with(uri.getHost(), cookie.domain) && cxx20::starts_with(uri.getPath(), cookie.path)) return &cookie; @@ -114,7 +114,7 @@ const CookieInfo* HttpCookie::getMatchCookie(const Uri& uri) const void HttpCookie::updateOrAddCookie(CookieInfo* cookie) { - for (auto& _cookie : _cookies) + for (auto&& _cookie : _cookies) { if (cookie->isSame(_cookie)) { @@ -264,7 +264,7 @@ void HttpCookie::writeFile() std::string line; char expires[32] = {0}; // LONGLONG_STRING_SIZE=20 - for (auto& cookie : _cookies) + for (auto&& cookie : _cookies) { line.clear(); line.append(cookie.domain); diff --git a/core/network/Uri.cpp b/core/network/Uri.cpp index bc8661a5e4..aec1e5a02f 100644 --- a/core/network/Uri.cpp +++ b/core/network/Uri.cpp @@ -58,7 +58,7 @@ std::string submatch(const std::smatch& m, int idx) template void toLower(String& s) { - for (auto& c : s) + for (auto&& c : s) { c = char(tolower(c)); } diff --git a/core/physics/CCPhysicsBody.cpp b/core/physics/CCPhysicsBody.cpp index 0a5de00c8c..3392ce06cf 100644 --- a/core/physics/CCPhysicsBody.cpp +++ b/core/physics/CCPhysicsBody.cpp @@ -115,7 +115,7 @@ PhysicsBody::PhysicsBody() PhysicsBody::~PhysicsBody() { - for (auto& joint : _joints) + for (auto&& joint : _joints) { PhysicsBody* other = joint->getBodyA() == this ? joint->getBodyB() : joint->getBodyA(); other->removeJoint(joint); @@ -367,7 +367,7 @@ void PhysicsBody::setRotation(float rotation) void PhysicsBody::setScale(float scaleX, float scaleY) { - for (auto& shape : _shapes) + for (auto&& shape : _shapes) { _area -= shape->getArea(); if (!_massSetByUser) @@ -674,7 +674,7 @@ void PhysicsBody::setMoment(float moment) PhysicsShape* PhysicsBody::getShape(int tag) const { - for (auto& shape : _shapes) + for (auto&& shape : _shapes) { if (shape->getTag() == tag) { @@ -687,7 +687,7 @@ PhysicsShape* PhysicsBody::getShape(int tag) const void PhysicsBody::removeShape(int tag, bool reduceMassAndMoment /* = true*/) { - for (auto& shape : _shapes) + for (auto&& shape : _shapes) { if (shape->getTag() == tag) { @@ -725,7 +725,7 @@ void PhysicsBody::removeShape(PhysicsShape* shape, bool reduceMassAndMoment /* = void PhysicsBody::removeAllShapes(bool reduceMassAndMoment /* = true*/) { - for (auto& child : _shapes) + for (auto&& child : _shapes) { PhysicsShape* shape = dynamic_cast(child); @@ -806,7 +806,7 @@ void PhysicsBody::update(float delta) void PhysicsBody::setCategoryBitmask(int bitmask) { - for (auto& shape : _shapes) + for (auto&& shape : _shapes) { shape->setCategoryBitmask(bitmask); } @@ -826,7 +826,7 @@ int PhysicsBody::getCategoryBitmask() const void PhysicsBody::setContactTestBitmask(int bitmask) { - for (auto& shape : _shapes) + for (auto&& shape : _shapes) { shape->setContactTestBitmask(bitmask); } @@ -846,7 +846,7 @@ int PhysicsBody::getContactTestBitmask() const void PhysicsBody::setCollisionBitmask(int bitmask) { - for (auto& shape : _shapes) + for (auto&& shape : _shapes) { shape->setCollisionBitmask(bitmask); } @@ -866,7 +866,7 @@ int PhysicsBody::getCollisionBitmask() const void PhysicsBody::setGroup(int group) { - for (auto& shape : _shapes) + for (auto&& shape : _shapes) { shape->setGroup(group); } diff --git a/core/physics/CCPhysicsJoint.cpp b/core/physics/CCPhysicsJoint.cpp index 1027880ff1..e43adfc1c4 100644 --- a/core/physics/CCPhysicsJoint.cpp +++ b/core/physics/CCPhysicsJoint.cpp @@ -171,7 +171,7 @@ bool PhysicsJoint::initJoint() ret = createConstraints(); AX_BREAK_IF(!ret); - for (auto subjoint : _cpConstraints) + for (auto&& subjoint : _cpConstraints) { cpConstraintSetMaxForce(subjoint, _maxForce); cpConstraintSetErrorBias(subjoint, cpfpow(1.0f - 0.15f, 60.0f)); @@ -235,7 +235,7 @@ void PhysicsJoint::setMaxForce(float force) { delay([this, force]() { _maxForce = force; - for (auto joint : _cpConstraints) + for (auto&& joint : _cpConstraints) { cpConstraintSetMaxForce(joint, force); } @@ -244,7 +244,7 @@ void PhysicsJoint::setMaxForce(float force) else { _maxForce = force; - for (auto joint : _cpConstraints) + for (auto&& joint : _cpConstraints) { cpConstraintSetMaxForce(joint, force); } diff --git a/core/physics/CCPhysicsShape.cpp b/core/physics/CCPhysicsShape.cpp index 77dab22b80..d50b8a6dda 100644 --- a/core/physics/CCPhysicsShape.cpp +++ b/core/physics/CCPhysicsShape.cpp @@ -66,7 +66,7 @@ PhysicsShape::PhysicsShape() PhysicsShape::~PhysicsShape() { - for (auto shape : _cpShapes) + for (auto&& shape : _cpShapes) { cpShapeFree(shape); } @@ -269,7 +269,7 @@ void PhysicsShape::setBody(PhysicsBody* body) _body->removeShape(this); } - for (auto shape : _cpShapes) + for (auto&& shape : _cpShapes) { cpShapeSetBody(shape, body == nullptr ? s_sharedBody : body->_cpBody); } @@ -794,7 +794,7 @@ Vec2 PhysicsShapeEdgePolygon::getCenter() int count = (int)_cpShapes.size(); cpVect* points = new cpVect[count]; int i = 0; - for (auto shape : _cpShapes) + for (auto&& shape : _cpShapes) { points[i++] = cpSegmentShapeGetA(shape); } @@ -808,7 +808,7 @@ Vec2 PhysicsShapeEdgePolygon::getCenter() void PhysicsShapeEdgePolygon::getPoints(axis::Vec2* outPoints) const { int i = 0; - for (auto shape : _cpShapes) + for (auto&& shape : _cpShapes) { outPoints[i++] = PhysicsHelper::cpv2vec2(cpSegmentShapeGetA(shape)); } @@ -841,7 +841,7 @@ void PhysicsShapeEdgePolygon::updateScale() cpFloat factorX = _newScaleX / _scaleX; cpFloat factorY = _newScaleY / _scaleY; - for (auto shape : _cpShapes) + for (auto&& shape : _cpShapes) { cpVect a = cpSegmentShapeGetA(shape); a.x *= factorX; @@ -899,7 +899,7 @@ Vec2 PhysicsShapeEdgeChain::getCenter() int count = (int)_cpShapes.size() + 1; cpVect* points = new cpVect[count]; int i = 0; - for (auto shape : _cpShapes) + for (auto&& shape : _cpShapes) { points[i++] = cpSegmentShapeGetA(shape); } @@ -915,7 +915,7 @@ Vec2 PhysicsShapeEdgeChain::getCenter() void PhysicsShapeEdgeChain::getPoints(Vec2* outPoints) const { int i = 0; - for (auto shape : _cpShapes) + for (auto&& shape : _cpShapes) { outPoints[i++] = PhysicsHelper::cpv2vec2(cpSegmentShapeGetA(shape)); } @@ -933,7 +933,7 @@ void PhysicsShapeEdgeChain::updateScale() cpFloat factorX = _newScaleX / _scaleX; cpFloat factorY = _newScaleY / _scaleY; - for (auto shape : _cpShapes) + for (auto&& shape : _cpShapes) { cpVect a = cpSegmentShapeGetA(shape); a.x *= factorX; @@ -951,7 +951,7 @@ void PhysicsShape::setGroup(int group) { if (group < 0) { - for (auto shape : _cpShapes) + for (auto&& shape : _cpShapes) { cpShapeSetFilter(shape, cpShapeFilterNew(group, CP_ALL_CATEGORIES, CP_ALL_CATEGORIES)); } @@ -962,7 +962,7 @@ void PhysicsShape::setGroup(int group) bool PhysicsShape::containsPoint(const Vec2& point) const { - for (auto shape : _cpShapes) + for (auto&& shape : _cpShapes) { if (cpShapePointQuery(shape, PhysicsHelper::vec22cpv(point), nullptr) < 0) { diff --git a/core/physics/CCPhysicsWorld.cpp b/core/physics/CCPhysicsWorld.cpp index f1793f3133..3ee362c54b 100644 --- a/core/physics/CCPhysicsWorld.cpp +++ b/core/physics/CCPhysicsWorld.cpp @@ -571,7 +571,7 @@ void PhysicsWorld::doAddBody(PhysicsBody* body) } // add shapes to space - for (auto& shape : body->getShapes()) + for (auto&& shape : body->getShapes()) { addShape(dynamic_cast(shape)); } @@ -604,14 +604,14 @@ void PhysicsWorld::updateBodies() // make a copy. auto addCopy = _delayAddBodies; _delayAddBodies.clear(); - for (auto& body : addCopy) + for (auto&& body : addCopy) { doAddBody(body); } auto removeCopy = _delayRemoveBodies; _delayRemoveBodies.clear(); - for (auto& body : removeCopy) + for (auto&& body : removeCopy) { doRemoveBody(body); } @@ -619,7 +619,7 @@ void PhysicsWorld::updateBodies() void PhysicsWorld::removeBody(int tag) { - for (auto& body : _bodies) + for (auto&& body : _bodies) { if (body->getTag() == tag) { @@ -639,7 +639,7 @@ void PhysicsWorld::removeBody(PhysicsBody* body) // destroy the body's joints auto removeCopy = body->_joints; - for (auto joint : removeCopy) + for (auto&& joint : removeCopy) { removeJoint(joint, true); } @@ -716,7 +716,7 @@ void PhysicsWorld::updateJoints() return; } - for (auto joint : _delayAddJoints) + for (auto&& joint : _delayAddJoints) { joint->_world = this; if (joint->initJoint()) @@ -730,13 +730,13 @@ void PhysicsWorld::updateJoints() } _delayAddJoints.clear(); - for (auto joint : _delayRemoveJoints) + for (auto&& joint : _delayRemoveJoints) { doRemoveJoint(joint); } _delayRemoveJoints.clear(); - for (auto joint : _joints) + for (auto&& joint : _joints) { joint->flushDelayTasks(); } @@ -746,7 +746,7 @@ void PhysicsWorld::removeShape(PhysicsShape* shape) { if (shape) { - for (auto cps : shape->_cpShapes) + for (auto&& cps : shape->_cpShapes) { if (cpSpaceContainsShape(_cpSpace, cps)) { @@ -780,7 +780,7 @@ void PhysicsWorld::addJoint(PhysicsJoint* joint) void PhysicsWorld::removeAllJoints(bool destroy) { auto removeCopy = _joints; - for (auto joint : removeCopy) + for (auto&& joint : removeCopy) { removeJoint(joint, destroy); } @@ -790,7 +790,7 @@ void PhysicsWorld::addShape(PhysicsShape* physicsShape) { if (physicsShape) { - for (auto shape : physicsShape->_cpShapes) + for (auto&& shape : physicsShape->_cpShapes) { cpSpaceAddShape(_cpSpace, shape); } @@ -802,7 +802,7 @@ void PhysicsWorld::doRemoveBody(PhysicsBody* body) AXASSERT(body != nullptr, "the body can not be nullptr"); // remove shapes - for (auto& shape : body->getShapes()) + for (auto&& shape : body->getShapes()) { removeShape(shape); } @@ -816,7 +816,7 @@ void PhysicsWorld::doRemoveBody(PhysicsBody* body) void PhysicsWorld::doRemoveJoint(PhysicsJoint* joint) { - for (auto constraint : joint->_cpConstraints) + for (auto&& constraint : joint->_cpConstraints) { cpSpaceRemoveConstraint(_cpSpace, constraint); } @@ -841,7 +841,7 @@ void PhysicsWorld::doRemoveJoint(PhysicsJoint* joint) void PhysicsWorld::removeAllBodies() { - for (auto& child : _bodies) + for (auto&& child : _bodies) { removeBodyOrDelay(child); child->_world = nullptr; @@ -868,7 +868,7 @@ const Vector& PhysicsWorld::getAllBodies() const PhysicsBody* PhysicsWorld::getBody(int tag) const { - for (auto& body : _bodies) + for (auto&& body : _bodies) { if (body->getTag() == tag) { @@ -974,7 +974,7 @@ void PhysicsWorld::update(float delta, bool userCall /* = false*/) # else cpHastySpaceStep(_cpSpace, dt); # endif - for (auto& body : _bodies) + for (auto&& body : _bodies) { body->update(dt); } @@ -1062,7 +1062,7 @@ void PhysicsWorld::beforeSimulation(Node* node, physicsBody->beforeSimulation(parentToWorldTransform, nodeToWorldTransform, scaleX, scaleY, rotation); } - for (auto child : node->getChildren()) + for (auto&& child : node->getChildren()) beforeSimulation(child, nodeToWorldTransform, scaleX, scaleY, rotation); } @@ -1077,7 +1077,7 @@ void PhysicsWorld::afterSimulation(Node* node, const Mat4& parentToWorldTransfor physicsBody->afterSimulation(parentToWorldTransform, parentRotation); } - for (auto child : node->getChildren()) + for (auto&& child : node->getChildren()) afterSimulation(child, nodeToWorldTransform, nodeRotation); } diff --git a/core/physics3d/CCPhysics3DObject.cpp b/core/physics3d/CCPhysics3DObject.cpp index 1843a70637..89308af06c 100644 --- a/core/physics3d/CCPhysics3DObject.cpp +++ b/core/physics3d/CCPhysics3DObject.cpp @@ -41,7 +41,7 @@ Physics3DRigidBody::~Physics3DRigidBody() { if (_physicsWorld) { - for (auto constraint : _constraintList) + for (auto&& constraint : _constraintList) { _physicsWorld->removePhysics3DConstraint(constraint); } @@ -412,7 +412,7 @@ public: Physics3DObject* getPhysicsObject(const btCollisionObject* btObj) { - for (auto it : _collider->getPhysicsWorld()->getPhysicsObjects()) + for (auto&& it : _collider->getPhysicsWorld()->getPhysicsObjects()) { if (it->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY) { diff --git a/core/physics3d/CCPhysics3DShape.cpp b/core/physics3d/CCPhysics3DShape.cpp index 10eed4ac3e..182d7216ed 100644 --- a/core/physics3d/CCPhysics3DShape.cpp +++ b/core/physics3d/CCPhysics3DShape.cpp @@ -49,7 +49,7 @@ Physics3DShape::~Physics3DShape() # if (AX_ENABLE_BULLET_INTEGRATION) AX_SAFE_DELETE(_btShape); AX_SAFE_DELETE_ARRAY(_heightfieldData); - for (auto iter : _compoundChildShapes) + for (auto&& iter : _compoundChildShapes) { AX_SAFE_RELEASE(iter); } @@ -206,7 +206,7 @@ bool Physics3DShape::initCompoundShape(const std::vectoraddChildShape(convertMat4TobtTransform(iter.second), iter.first->getbtShape()); AX_SAFE_RETAIN(iter.first); diff --git a/core/physics3d/CCPhysics3DWorld.cpp b/core/physics3d/CCPhysics3DWorld.cpp index 1ccffe709d..230229f35f 100644 --- a/core/physics3d/CCPhysics3DWorld.cpp +++ b/core/physics3d/CCPhysics3DWorld.cpp @@ -56,7 +56,7 @@ Physics3DWorld::~Physics3DWorld() AX_SAFE_DELETE(_solver); AX_SAFE_DELETE(_btPhyiscsWorld); AX_SAFE_DELETE(_debugDrawer); - for (auto it : _physicsComponents) + for (auto&& it : _physicsComponents) it->setPhysics3DObject(nullptr); _physicsComponents.clear(); } @@ -166,7 +166,7 @@ void Physics3DWorld::removePhysics3DObject(Physics3DObject* physicsObj) void Physics3DWorld::removeAllPhysics3DObjects() { - for (auto it : _objects) + for (auto&& it : _objects) { if (it->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY) { @@ -219,13 +219,13 @@ void Physics3DWorld::removePhysics3DConstraint(Physics3DConstraint* constraint) void Physics3DWorld::removeAllPhysics3DConstraints() { - for (auto it : _objects) + for (auto&& it : _objects) { auto type = it->getObjType(); if (type == Physics3DObject::PhysicsObjType::RIGID_BODY) { auto& constraints = static_cast(it)->_constraintList; - for (auto constraint : constraints) + for (auto&& constraint : constraints) { _btPhyiscsWorld->removeConstraint(constraint->getbtContraint()); constraint->release(); @@ -234,7 +234,7 @@ void Physics3DWorld::removeAllPhysics3DConstraints() } } - for (auto constraint : _constraints) + for (auto&& constraint : _constraints) { removePhysics3DConstraintFromBullet(constraint); constraint->release(); @@ -260,13 +260,13 @@ void Physics3DWorld::stepSimulate(float dt) { setGhostPairCallback(); // should sync kinematic node before simulation - for (auto it : _physicsComponents) + for (auto&& it : _physicsComponents) { it->preSimulate(); } _btPhyiscsWorld->stepSimulation(dt, 3); // sync dynamic node after simulation - for (auto it : _physicsComponents) + for (auto&& it : _physicsComponents) { it->postSimulate(); } @@ -328,7 +328,7 @@ bool Physics3DWorld::sweepShape(Physics3DShape* shape, Physics3DObject* Physics3DWorld::getPhysicsObject(const btCollisionObject* btObj) { - for (auto it : _objects) + for (auto&& it : _objects) { if (it->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY) { @@ -390,7 +390,7 @@ bool Physics3DWorld::needCollisionChecking() if (_collisionCheckingFlag) { _needCollisionChecking = false; - for (auto it : _objects) + for (auto&& it : _objects) { if (it->getCollisionCallback() != nullptr) { @@ -408,7 +408,7 @@ void Physics3DWorld::setGhostPairCallback() if (_needGhostPairCallbackChecking) { bool needCallback = false; - for (auto it : _objects) + for (auto&& it : _objects) { if (it->getObjType() == Physics3DObject::PhysicsObjType::COLLIDER) { diff --git a/core/platform/CCGLView.cpp b/core/platform/CCGLView.cpp index 67b34fd43c..bfef839f00 100644 --- a/core/platform/CCGLView.cpp +++ b/core/platform/CCGLView.cpp @@ -452,7 +452,7 @@ void GLView::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->dispatchEvent(&touchEvent); - for (auto& touch : touchEvent._touches) + for (auto&& touch : touchEvent._touches) { // release the touch object. touch->release(); diff --git a/core/platform/desktop/CCGLViewImpl-desktop.cpp b/core/platform/desktop/CCGLViewImpl-desktop.cpp index 92c160eea8..6f7f71675f 100644 --- a/core/platform/desktop/CCGLViewImpl-desktop.cpp +++ b/core/platform/desktop/CCGLViewImpl-desktop.cpp @@ -297,7 +297,7 @@ GLViewImpl::GLViewImpl(bool initglfw) { _viewName = "AX_10"; g_keyCodeMap.clear(); - for (auto& item : g_keyCodeStructArray) + for (auto&& item : g_keyCodeStructArray) { g_keyCodeMap[item.glfwKeyCode] = item.keyCode; } @@ -634,7 +634,7 @@ void GLViewImpl::setIcon(const std::vector& filelist) const glfwSetWindowIcon(window, iconsCount, images); AX_SAFE_DELETE_ARRAY(images); - for (auto& icon : icons) + for (auto&& icon : icons) { AX_SAFE_DELETE(icon); } diff --git a/core/renderer/CCMaterial.cpp b/core/renderer/CCMaterial.cpp index a9c5c59955..244dac24ad 100644 --- a/core/renderer/CCMaterial.cpp +++ b/core/renderer/CCMaterial.cpp @@ -53,7 +53,7 @@ std::string replaceDefines(std::string_view compileTimeDefines) auto defineParts = Console::Utility::split(compileTimeDefines, ';'); std::stringstream ss; - for (auto& p : defineParts) + for (auto&& p : defineParts) { if (p.find("#define ") == std::string::npos) { diff --git a/core/renderer/CCQuadCommand.cpp b/core/renderer/CCQuadCommand.cpp index a6224e041d..c6531112c3 100644 --- a/core/renderer/CCQuadCommand.cpp +++ b/core/renderer/CCQuadCommand.cpp @@ -41,7 +41,7 @@ QuadCommand::QuadCommand() : _indexSize(-1), _ownedIndices() {} QuadCommand::~QuadCommand() { - for (auto& indices : _ownedIndices) + for (auto&& indices : _ownedIndices) { AX_SAFE_DELETE_ARRAY(indices); } diff --git a/core/renderer/CCRenderCommandPool.h b/core/renderer/CCRenderCommandPool.h index e0777a81c4..6766d0a4cf 100644 --- a/core/renderer/CCRenderCommandPool.h +++ b/core/renderer/CCRenderCommandPool.h @@ -45,7 +45,7 @@ public: // AXLOG("All RenderCommand should not be used when Pool is released!"); // } _freePool.clear(); - for (auto& allocatedPoolBlock : _allocatedPoolBlocks) + for (auto&& allocatedPoolBlock : _allocatedPoolBlocks) { delete[] allocatedPoolBlock; allocatedPoolBlock = nullptr; diff --git a/core/renderer/CCRenderer.cpp b/core/renderer/CCRenderer.cpp index 694bd30b05..9333965426 100644 --- a/core/renderer/CCRenderer.cpp +++ b/core/renderer/CCRenderer.cpp @@ -179,7 +179,7 @@ Renderer::~Renderer() _renderGroups.clear(); _groupCommandManager->release(); - for (auto clearCommand : _callbackCommandsPool) + for (auto&& clearCommand : _callbackCommandsPool) delete clearCommand; _callbackCommandsPool.clear(); @@ -389,7 +389,7 @@ void Renderer::render() { // Process render commands // 1. Sort render commands based on ID - for (auto& renderqueue : _renderGroups) + for (auto&& renderqueue : _renderGroups) { renderqueue.sort(); } @@ -932,10 +932,10 @@ void Renderer::setScissorRect(float x, float y, float width, float height) // TriangleCommandBufferManager Renderer::TriangleCommandBufferManager::~TriangleCommandBufferManager() { - for (auto& vertexBuffer : _vertexBufferPool) + for (auto&& vertexBuffer : _vertexBufferPool) vertexBuffer->release(); - for (auto& indexBuffer : _indexBufferPool) + for (auto&& indexBuffer : _indexBufferPool) indexBuffer->release(); } diff --git a/core/renderer/CCTextureCache.cpp b/core/renderer/CCTextureCache.cpp index 89dbf28020..ae03c7e1cf 100644 --- a/core/renderer/CCTextureCache.cpp +++ b/core/renderer/CCTextureCache.cpp @@ -69,7 +69,7 @@ TextureCache::~TextureCache() { AXLOGINFO("deallocing TextureCache: %p", this); - for (auto& texture : _textures) + for (auto&& texture : _textures) texture.second->release(); AX_SAFE_DELETE(_loadingThread); @@ -231,7 +231,7 @@ void TextureCache::unbindImageAsync(std::string_view callbackKey) return; } - for (auto& asyncStruct : _asyncStructQueue) + for (auto&& asyncStruct : _asyncStructQueue) { if (asyncStruct->callbackKey == callbackKey) { @@ -246,7 +246,7 @@ void TextureCache::unbindAllImageAsync() { return; } - for (auto& asyncStruct : _asyncStructQueue) + for (auto&& asyncStruct : _asyncStructQueue) { asyncStruct->callback = nullptr; } @@ -551,7 +551,7 @@ bool TextureCache::reloadTexture(std::string_view fileName) void TextureCache::removeAllTextures() { - for (auto& texture : _textures) + for (auto&& texture : _textures) { texture.second->release(); } @@ -631,7 +631,7 @@ Texture2D* TextureCache::getTextureForKey(std::string_view textureKeyName) const std::string TextureCache::getTextureFilePath(axis::Texture2D* texture) const { - for (auto& item : _textures) + for (auto&& item : _textures) { if (item.second == texture) { @@ -661,7 +661,7 @@ std::string TextureCache::getCachedTextureInfo() const unsigned int count = 0; unsigned int totalBytes = 0; - for (auto& texture : _textures) + for (auto&& texture : _textures) { memset(buftmp, 0, sizeof(buftmp)); @@ -816,7 +816,7 @@ void VolatileTextureMgr::addStringTexture(Texture2D* tt, const char* text, const void VolatileTextureMgr::removeTexture(Texture2D* t) { - for (auto& item : _textures) + for (auto&& item : _textures) { VolatileTexture* vt = item; if (vt->_texture == t) @@ -833,7 +833,7 @@ void VolatileTextureMgr::reloadAllTextures() _isReloading = true; AXLOG("reload all texture"); - for (auto& texture : _textures) + for (auto&& texture : _textures) { VolatileTexture* vt = texture; diff --git a/core/renderer/CCTextureCube.cpp b/core/renderer/CCTextureCube.cpp index afc0b24cb7..5339f75582 100644 --- a/core/renderer/CCTextureCube.cpp +++ b/core/renderer/CCTextureCube.cpp @@ -254,7 +254,7 @@ bool TextureCube::init(std::string_view positive_x, free(pData); } - for (auto img : images) + for (auto&& img : images) { AX_SAFE_RELEASE(img); } diff --git a/core/renderer/backend/ProgramCache.cpp b/core/renderer/backend/ProgramCache.cpp index 48274548ce..a964bf7a04 100644 --- a/core/renderer/backend/ProgramCache.cpp +++ b/core/renderer/backend/ProgramCache.cpp @@ -71,7 +71,7 @@ void ProgramCache::destroyInstance() ProgramCache::~ProgramCache() { - for (auto& program : _cachedPrograms) + for (auto&& program : _cachedPrograms) { AX_SAFE_RELEASE(program.second); } @@ -255,7 +255,7 @@ void ProgramCache::removeUnusedProgram() void ProgramCache::removeAllPrograms() { ProgramStateRegistry::getInstance()->clearPrograms(); - for (auto& program : _cachedPrograms) + for (auto&& program : _cachedPrograms) { program.second->release(); } diff --git a/core/renderer/backend/ProgramState.cpp b/core/renderer/backend/ProgramState.cpp index 267ac6e688..6746320252 100644 --- a/core/renderer/backend/ProgramState.cpp +++ b/core/renderer/backend/ProgramState.cpp @@ -124,13 +124,13 @@ TextureInfo::~TextureInfo() void TextureInfo::retainTextures() { - for (auto& texture : textures) + for (auto&& texture : textures) AX_SAFE_RETAIN(texture); } void TextureInfo::releaseTextures() { - for (auto& texture : textures) + for (auto&& texture : textures) AX_SAFE_RELEASE(texture); textures.clear(); } diff --git a/core/renderer/backend/ShaderCache.cpp b/core/renderer/backend/ShaderCache.cpp index ae89046f08..866e2a7d3c 100644 --- a/core/renderer/backend/ShaderCache.cpp +++ b/core/renderer/backend/ShaderCache.cpp @@ -50,7 +50,7 @@ void ShaderCache::destroyInstance() ShaderCache::~ShaderCache() { - for (auto& shaderModule : _cachedShaders) + for (auto&& shaderModule : _cachedShaders) { AX_SAFE_RELEASE(shaderModule.second); } diff --git a/core/renderer/backend/opengl/CommandBufferGL.cpp b/core/renderer/backend/opengl/CommandBufferGL.cpp index 5871fc61ef..f945f3abb0 100644 --- a/core/renderer/backend/opengl/CommandBufferGL.cpp +++ b/core/renderer/backend/opengl/CommandBufferGL.cpp @@ -292,7 +292,7 @@ void CommandBufferGL::setUniforms(ProgramGL* program) const if (_programState) { auto& callbacks = _programState->getCallbackUniforms(); - for (auto& cb : callbacks) + for (auto&& cb : callbacks) cb.second(_programState, cb.first); auto& uniformInfos = _programState->getProgram()->getAllActiveUniformInfo(ShaderStage::VERTEX); @@ -301,7 +301,7 @@ void CommandBufferGL::setUniforms(ProgramGL* program) const _programState->getVertexUniformBuffer(&buffer, bufferSize); int i = 0; - for (auto& iter : uniformInfos) + for (auto&& iter : uniformInfos) { auto& uniformInfo = iter.second; if (uniformInfo.size <= 0) diff --git a/core/renderer/backend/opengl/TextureGL.cpp b/core/renderer/backend/opengl/TextureGL.cpp index 6056eeefc0..6b5b658f73 100644 --- a/core/renderer/backend/opengl/TextureGL.cpp +++ b/core/renderer/backend/opengl/TextureGL.cpp @@ -122,7 +122,7 @@ GLuint TextureInfoGL::ensure(int index, GLenum target) void TextureInfoGL::recreateAll(GLenum target) { int idx = 0; - for (auto& texID : textures) + for (auto&& texID : textures) { if (texID) { diff --git a/core/ui/LayoutHelper.cpp b/core/ui/LayoutHelper.cpp index 8f88ac2ffe..71074f7f20 100644 --- a/core/ui/LayoutHelper.cpp +++ b/core/ui/LayoutHelper.cpp @@ -324,7 +324,7 @@ void LayoutHelper::setNodeGroupBottom(const std::vector& nodes, float bot void LayoutHelper::moveNodeGroupHorizontally(const std::vector& nodes, float delta) { - for (auto node : nodes) + for (auto&& node : nodes) { node->setPositionX(node->getPositionX() + delta); } @@ -332,7 +332,7 @@ void LayoutHelper::moveNodeGroupHorizontally(const std::vector& nodes, fl void LayoutHelper::moveNodeGroupVertically(const std::vector& nodes, float delta) { - for (auto node : nodes) + for (auto&& node : nodes) { node->setPositionY(node->getPositionY() - delta); } diff --git a/core/ui/UIHelper.cpp b/core/ui/UIHelper.cpp index 008506fdc8..0b37c3843c 100644 --- a/core/ui/UIHelper.cpp +++ b/core/ui/UIHelper.cpp @@ -74,7 +74,7 @@ Widget* Helper::seekWidgetByName(Widget* root, std::string_view name) return root; } const auto& arrayRootChildren = root->getChildren(); - for (auto& subWidget : arrayRootChildren) + for (auto&& subWidget : arrayRootChildren) { Widget* child = dynamic_cast(subWidget); if (child) @@ -101,7 +101,7 @@ Widget* Helper::seekActionWidgetByActionTag(Widget* root, int tag) return root; } const auto& arrayRootChildren = root->getChildren(); - for (auto& subWidget : arrayRootChildren) + for (auto&& subWidget : arrayRootChildren) { Widget* child = dynamic_cast(subWidget); if (child) @@ -151,7 +151,7 @@ void Helper::doLayout(axis::Node* rootNode) return; } - for (auto& node : rootNode->getChildren()) + for (auto&& node : rootNode->getChildren()) { auto com = node->getComponent(__LAYOUT_COMPONENT_NAME); Node* parent = node->getParent(); diff --git a/core/ui/UILayout.cpp b/core/ui/UILayout.cpp index d5c98781b5..965f6d7126 100644 --- a/core/ui/UILayout.cpp +++ b/core/ui/UILayout.cpp @@ -116,7 +116,7 @@ void Layout::setGlobalZOrder(float globalZOrder) if (_clippingStencil) _clippingStencil->setGlobalZOrder(globalZOrder); - for (auto& child : _children) + for (auto&& child : _children) child->setGlobalZOrder(globalZOrder); } @@ -886,7 +886,7 @@ void Layout::setLayoutType(Type type) { _layoutType = type; - for (auto& child : _children) + for (auto&& child : _children) { Widget* widgetChild = dynamic_cast(child); if (widgetChild) diff --git a/core/ui/UILayoutComponent.cpp b/core/ui/UILayoutComponent.cpp index b47f938623..e1a53814b7 100644 --- a/core/ui/UILayoutComponent.cpp +++ b/core/ui/UILayoutComponent.cpp @@ -649,7 +649,7 @@ void LayoutComponent::refreshLayout() page->forceDoLayout(); Vector _widgetVector = page->getItems(); - for (auto& item : _widgetVector) + for (auto&& item : _widgetVector) { ui::Helper::doLayout(item); } diff --git a/core/ui/UILayoutManager.cpp b/core/ui/UILayoutManager.cpp index 86e65ea635..466782c77d 100644 --- a/core/ui/UILayoutManager.cpp +++ b/core/ui/UILayoutManager.cpp @@ -43,7 +43,7 @@ void LinearHorizontalLayoutManager::doLayout(LayoutProtocol* layout) Vec2 layoutSize = layout->getLayoutContentSize(); Vector container = layout->getLayoutElements(); float leftBoundary = 0.0f; - for (auto& subWidget : container) + for (auto&& subWidget : container) { Widget* child = dynamic_cast(subWidget); if (child) @@ -94,7 +94,7 @@ void LinearVerticalLayoutManager::doLayout(LayoutProtocol* layout) Vector container = layout->getLayoutElements(); float topBoundary = layoutSize.height; - for (auto& subWidget : container) + for (auto&& subWidget : container) { LayoutParameterProtocol* child = dynamic_cast(subWidget); if (child) @@ -217,7 +217,7 @@ Vector RelativeLayoutManager::getAllWidgets(axis::ui::LayoutProtocol* l { Vector container = layout->getLayoutElements(); Vector widgetChildren; - for (auto& subWidget : container) + for (auto&& subWidget : container) { Widget* child = dynamic_cast(subWidget); if (child) @@ -240,7 +240,7 @@ Widget* RelativeLayoutManager::getRelativeWidget(Widget* widget) if (!relativeName.empty()) { - for (auto& sWidget : _widgetChildren) + for (auto&& sWidget : _widgetChildren) { if (sWidget) { @@ -584,7 +584,7 @@ void RelativeLayoutManager::doLayout(LayoutProtocol* layout) while (_unlayoutChildCount > 0) { - for (auto& subWidget : _widgetChildren) + for (auto&& subWidget : _widgetChildren) { _widget = static_cast(subWidget); diff --git a/core/ui/UIListView.cpp b/core/ui/UIListView.cpp index f693b587ce..be31038685 100644 --- a/core/ui/UIListView.cpp +++ b/core/ui/UIListView.cpp @@ -116,7 +116,7 @@ void ListView::updateInnerContainerSize() { size_t length = _items.size(); float totalHeight = (length == 0) ? 0.0f : (length - 1) * _itemsMargin + (_topPadding + _bottomPadding); - for (auto& item : _items) + for (auto&& item : _items) { totalHeight += item->getContentSize().height * item->getScaleY(); } @@ -129,7 +129,7 @@ void ListView::updateInnerContainerSize() { size_t length = _items.size(); float totalWidth = (length == 0) ? 0.0f : (length - 1) * _itemsMargin + (_leftPadding + _rightPadding); - for (auto& item : _items) + for (auto&& item : _items) { totalWidth += item->getContentSize().width * item->getScaleX(); } @@ -914,7 +914,7 @@ Widget* ListView::createCloneInstance() void ListView::copyClonedWidgetChildren(Widget* model) { auto& arrayItems = static_cast(model)->getItems(); - for (auto& item : arrayItems) + for (auto&& item : arrayItems) { pushBackCustomItem(item->clone()); } diff --git a/core/ui/UIPageViewIndicator.cpp b/core/ui/UIPageViewIndicator.cpp index a22a3ec572..24efee8b71 100644 --- a/core/ui/UIPageViewIndicator.cpp +++ b/core/ui/UIPageViewIndicator.cpp @@ -135,7 +135,7 @@ void PageViewIndicator::rearrange() float totalSizeValue = sizeValue * numberOfItems + _spaceBetweenIndexNodes * (numberOfItems - 1); float posValue = -(totalSizeValue / 2) + (sizeValue / 2); - for (auto& indexNode : _indexNodes) + for (auto&& indexNode : _indexNodes) { Vec2 position; if (horizontal) @@ -165,7 +165,7 @@ void PageViewIndicator::setIndexNodesColor(const Color3B& indexNodesColor) { _indexNodesColor = indexNodesColor; - for (auto& indexNode : _indexNodes) + for (auto&& indexNode : _indexNodes) { indexNode->setColor(indexNodesColor); } @@ -174,7 +174,7 @@ void PageViewIndicator::setIndexNodesColor(const Color3B& indexNodesColor) void PageViewIndicator::setIndexNodesOpacity(uint8_t opacity) { _indexNodesOpacity = opacity; - for (auto& indexNode : _indexNodes) + for (auto&& indexNode : _indexNodes) indexNode->setOpacity(opacity); } @@ -187,7 +187,7 @@ void PageViewIndicator::setIndexNodesScale(float indexNodesScale) _indexNodesScale = indexNodesScale; _currentIndexNode->setScale(indexNodesScale); - for (auto& indexNode : _indexNodes) + for (auto&& indexNode : _indexNodes) { indexNode->setScale(_indexNodesScale); } @@ -205,14 +205,14 @@ void PageViewIndicator::setIndexNodesTexture(std::string_view texName, Widget::T { case Widget::TextureResType::LOCAL: _currentIndexNode->setTexture(texName); - for (auto& indexNode : _indexNodes) + for (auto&& indexNode : _indexNodes) { indexNode->setTexture(texName); } break; case Widget::TextureResType::PLIST: _currentIndexNode->setSpriteFrame(texName); - for (auto& indexNode : _indexNodes) + for (auto&& indexNode : _indexNodes) { indexNode->setSpriteFrame(texName); } @@ -281,7 +281,7 @@ void PageViewIndicator::clear() _currentOverlappingIndexNode->setVisible(true); _currentOverlappingIndexNode = nullptr; } - for (auto& indexNode : _indexNodes) + for (auto&& indexNode : _indexNodes) { removeProtectedChild(indexNode); } diff --git a/core/ui/UIRichText.cpp b/core/ui/UIRichText.cpp index 3dcce7dbdc..6c9a8cd7ef 100644 --- a/core/ui/UIRichText.cpp +++ b/core/ui/UIRichText.cpp @@ -1949,11 +1949,11 @@ void RichText::formatRenderers() float nextPosY = 0.0f; std::vector*, float>> rowWidthPairs; rowWidthPairs.reserve(_elementRenders.size()); - for (auto& element : _elementRenders) + for (auto&& element : _elementRenders) { float nextPosX = 0.0f; float maxY = 0.0f; - for (auto& iter : element) + for (auto&& iter : element) { iter->setAnchorPoint(Vec2::ZERO); iter->setPosition(nextPosX, nextPosY); @@ -1967,7 +1967,7 @@ void RichText::formatRenderers() rowWidthPairs.emplace_back(&element, nextPosX); } this->setContentSize(Vec2(newContentSizeWidth, -nextPosY)); - for (auto& row : rowWidthPairs) + for (auto&& row : rowWidthPairs) doHorizontalAlignment(*row.first, row.second); } else @@ -1980,7 +1980,7 @@ void RichText::formatRenderers() { Vector& row = _elementRenders[i]; float maxHeight = 0.0f; - for (auto& iter : row) + for (auto&& iter : row) { maxHeight = std::max(iter->getContentSize().height, maxHeight); } @@ -2004,7 +2004,7 @@ void RichText::formatRenderers() Vector& row = _elementRenders[i]; float nextPosX = 0.0f; nextPosY -= (i != 0 ? maxHeights[i] + verticalSpace : maxHeights[i]); - for (auto& iter : row) + for (auto&& iter : row) { iter->setAnchorPoint(Vec2::ZERO); iter->setPosition(nextPosX, nextPosY); @@ -2057,7 +2057,7 @@ void RichText::doHorizontalAlignment(const Vector& row, float rowWi const auto leftOver = getContentSize().width - (rowWidth + diff); const float leftPadding = getPaddingAmount(alignment, leftOver); const Vec2 offset(leftPadding, 0.f); - for (auto& node : row) + for (auto&& node : row) { node->setPosition(node->getPosition() + offset); } diff --git a/core/ui/UIScrollView.cpp b/core/ui/UIScrollView.cpp index 8ca34861ff..c737d5ccc4 100644 --- a/core/ui/UIScrollView.cpp +++ b/core/ui/UIScrollView.cpp @@ -363,7 +363,7 @@ void ScrollView::updateScrollBar(const Vec2& outOfBoundary) Vec2 ScrollView::calculateTouchMoveVelocity() const { float totalTime = 0; - for (auto& timeDelta : _touchMoveTimeDeltas) + for (auto&& timeDelta : _touchMoveTimeDeltas) { totalTime += timeDelta; } @@ -373,7 +373,7 @@ Vec2 ScrollView::calculateTouchMoveVelocity() const } Vec2 totalMovement; - for (auto& displacement : _touchMoveDisplacements) + for (auto&& displacement : _touchMoveDisplacements) { totalMovement += displacement; } diff --git a/core/ui/UITabControl.cpp b/core/ui/UITabControl.cpp index 552f4209d4..4146676e3b 100644 --- a/core/ui/UITabControl.cpp +++ b/core/ui/UITabControl.cpp @@ -50,7 +50,7 @@ TabControl::TabControl() TabControl::~TabControl() { - for (auto& item : _tabItems) + for (auto&& item : _tabItems) { if (item) AX_SAFE_DELETE(item); @@ -179,7 +179,7 @@ void TabControl::setHeaderDockPlace(TabControl::Dock dockPlace) initContainers(); auto anpoint = getHeaderAnchorWithDock(); - for (auto& item : _tabItems) + for (auto&& item : _tabItems) { item->header->setAnchorPoint(anpoint); } @@ -280,7 +280,7 @@ void TabControl::initContainers() break; } - for (auto& tabItem : _tabItems) + for (auto&& tabItem : _tabItems) { Layout* container = tabItem->container; container->setPosition(_containerPosition); @@ -440,7 +440,7 @@ void TabControl::ignoreHeadersTextureSize(bool ignore) return; _ignoreHeaderTextureSize = ignore; - for (auto& item : _tabItems) + for (auto&& item : _tabItems) { item->header->ignoreContentAdaptWithSize(!ignore); if (ignore) diff --git a/core/ui/UIWidget.cpp b/core/ui/UIWidget.cpp index 8b8e3f4e13..1b1a3caf76 100644 --- a/core/ui/UIWidget.cpp +++ b/core/ui/UIWidget.cpp @@ -517,7 +517,7 @@ void Widget::onSizeChanged() { if (!_usingLayoutComponent) { - for (auto& child : getChildren()) + for (auto&& child : getChildren()) { Widget* widgetChild = dynamic_cast(child); if (widgetChild) @@ -1136,7 +1136,7 @@ void Widget::copyClonedWidgetChildren(Widget* model) { auto& modelChildren = model->getChildren(); - for (auto& subWidget : modelChildren) + for (auto&& subWidget : modelChildren) { Widget* child = dynamic_cast(subWidget); if (child) @@ -1188,7 +1188,7 @@ void Widget::copyProperties(Widget* widget) copySpecialProperties(widget); Map& layoutParameterDic = widget->_layoutParameterDictionary; - for (auto& iter : layoutParameterDic) + for (auto&& iter : layoutParameterDic) { setLayoutParameter(iter.second->clone()); } diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index 4c07ca450c..f0d5491977 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -226,7 +226,7 @@ void Control::setOpacityModifyRGB(bool bOpacityModifyRGB) { _isOpacityModifyRGB = bOpacityModifyRGB; - for (auto child : _children) + for (auto&& child : _children) { child->setOpacityModifyRGB(bOpacityModifyRGB); } diff --git a/extensions/Particle3D/CCParticle3DRender.cpp b/extensions/Particle3D/CCParticle3DRender.cpp index 06e884c3a9..6579426962 100644 --- a/extensions/Particle3D/CCParticle3DRender.cpp +++ b/extensions/Particle3D/CCParticle3DRender.cpp @@ -117,7 +117,7 @@ void Particle3DQuadRender::render(Renderer* renderer, const Mat4& transform, Par Vec3 position; // particle position int vertexindex = 0; int index = 0; - for (auto iter : activeParticleList) + for (auto&& iter : activeParticleList) { auto particle = iter; Vec3 halfwidth = particle->width * 0.5f * right; @@ -283,7 +283,7 @@ void Particle3DQuadRender::reset() Particle3DModelRender::Particle3DModelRender() : _meshSize(Vec3::ONE) {} Particle3DModelRender::~Particle3DModelRender() { - for (auto iter : _meshList) + for (auto&& iter : _meshList) { iter->release(); } @@ -333,7 +333,7 @@ void Particle3DModelRender::render(Renderer* renderer, const Mat4& transform, Pa Quaternion q; transform.decompose(nullptr, &q, nullptr); unsigned int index = 0; - for (auto iter : activeParticleList) + for (auto&& iter : activeParticleList) { auto particle = iter; Mat4::createRotation(q * particle->orientation, &rotMat); @@ -350,7 +350,7 @@ void Particle3DModelRender::render(Renderer* renderer, const Mat4& transform, Pa void Particle3DModelRender::reset() { - for (auto iter : _meshList) + for (auto&& iter : _meshList) { iter->release(); } diff --git a/extensions/Particle3D/CCParticleSystem3D.cpp b/extensions/Particle3D/CCParticleSystem3D.cpp index a2bc66b5f0..c78d9ba905 100644 --- a/extensions/Particle3D/CCParticleSystem3D.cpp +++ b/extensions/Particle3D/CCParticleSystem3D.cpp @@ -133,7 +133,7 @@ void ParticleSystem3D::removeAffector(int index) void ParticleSystem3D::removeAllAffector() { // release all affectors - for (auto it : _affectors) + for (auto&& it : _affectors) { it->release(); } @@ -159,7 +159,7 @@ void ParticleSystem3D::update(float delta) _emitter->updateEmitter(particle, delta); } - for (auto& it : _affectors) + for (auto&& it : _affectors) { it->updateAffector(particle, delta); } diff --git a/extensions/Particle3D/CCParticleSystem3D.h b/extensions/Particle3D/CCParticleSystem3D.h index 4bca820146..7e116b9d65 100644 --- a/extensions/Particle3D/CCParticleSystem3D.h +++ b/extensions/Particle3D/CCParticleSystem3D.h @@ -142,7 +142,7 @@ public: void removeAllDatas() { lockAllDatas(); - for (auto iter : _locked) + for (auto&& iter : _locked) { delete iter; } diff --git a/extensions/Particle3D/PU/CCPUBeamRender.cpp b/extensions/Particle3D/PU/CCPUBeamRender.cpp index 757dc4fec5..0b51cbc447 100644 --- a/extensions/Particle3D/PU/CCPUBeamRender.cpp +++ b/extensions/Particle3D/PU/CCPUBeamRender.cpp @@ -64,7 +64,7 @@ void PUBeamRender::render(Renderer* renderer, const Mat4& transform, ParticleSys return; Vec3 basePosition = static_cast(_particleSystem)->getDerivedPosition(); - for (auto iter : particlePool.getActiveDataList()) + for (auto&& iter : particlePool.getActiveDataList()) { auto particle = static_cast(iter); auto visualData = static_cast(particle->visualData); diff --git a/extensions/Particle3D/PU/CCPUBoxCollider.cpp b/extensions/Particle3D/PU/CCPUBoxCollider.cpp index 5279de34dc..7df1c4a4ba 100644 --- a/extensions/Particle3D/PU/CCPUBoxCollider.cpp +++ b/extensions/Particle3D/PU/CCPUBoxCollider.cpp @@ -188,7 +188,7 @@ bool PUBoxCollider::isSmallestValue(float value, const Vec3& particlePosition) void PUBoxCollider::updatePUAffector(PUParticle3D* particle, float /*deltaTime*/) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; _predictedPosition = particle->position + _velocityScale * particle->direction; diff --git a/extensions/Particle3D/PU/CCPUCollisionAvoidanceAffector.cpp b/extensions/Particle3D/PU/CCPUCollisionAvoidanceAffector.cpp index 5d055f8ba4..f367126fc1 100644 --- a/extensions/Particle3D/PU/CCPUCollisionAvoidanceAffector.cpp +++ b/extensions/Particle3D/PU/CCPUCollisionAvoidanceAffector.cpp @@ -48,7 +48,7 @@ void PUCollisionAvoidanceAffector::setRadius(float radius) void PUCollisionAvoidanceAffector::updatePUAffector(PUParticle3D* /*particle*/, float /*deltaTime*/) { AXASSERT(0, "nonsupport yet"); - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) //{ // PUParticle3D *particle = iter; // // Activate spatial hashing diff --git a/extensions/Particle3D/PU/CCPUColorAffector.cpp b/extensions/Particle3D/PU/CCPUColorAffector.cpp index 5d76dc4e0c..0a41f69e56 100644 --- a/extensions/Particle3D/PU/CCPUColorAffector.cpp +++ b/extensions/Particle3D/PU/CCPUColorAffector.cpp @@ -86,7 +86,7 @@ void PUColorAffector::updatePUAffector(PUParticle3D* particle, float /*deltaTime if (_colorMap.empty()) return; - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; // Linear interpolation of the colour diff --git a/extensions/Particle3D/PU/CCPUDoAffectorEventHandler.cpp b/extensions/Particle3D/PU/CCPUDoAffectorEventHandler.cpp index 212f4facce..c6fbdc3ea8 100644 --- a/extensions/Particle3D/PU/CCPUDoAffectorEventHandler.cpp +++ b/extensions/Particle3D/PU/CCPUDoAffectorEventHandler.cpp @@ -46,7 +46,7 @@ void PUDoAffectorEventHandler::handle(PUParticleSystem3D* particleSystem, PUPart // Search all techniques in this ParticleSystem for an affector with the correct name PUParticleSystem3D* system = particleSystem->getParentParticleSystem(); auto children = system->getChildren(); - for (auto iter : children) + for (auto&& iter : children) { technique = dynamic_cast(iter); if (technique) diff --git a/extensions/Particle3D/PU/CCPUDoEnableComponentEventHandler.cpp b/extensions/Particle3D/PU/CCPUDoEnableComponentEventHandler.cpp index b7fb46cbaa..1313cd6235 100644 --- a/extensions/Particle3D/PU/CCPUDoEnableComponentEventHandler.cpp +++ b/extensions/Particle3D/PU/CCPUDoEnableComponentEventHandler.cpp @@ -54,7 +54,7 @@ void PUDoEnableComponentEventHandler::handle(PUParticleSystem3D* particleSystem, if (system) { auto children = system->getChildren(); - for (auto iter : children) + for (auto&& iter : children) { PUParticleSystem3D* child = dynamic_cast(iter); if (child) @@ -85,7 +85,7 @@ void PUDoEnableComponentEventHandler::handle(PUParticleSystem3D* particleSystem, if (system) { auto children = system->getChildren(); - for (auto iter : children) + for (auto&& iter : children) { PUParticleSystem3D* child = dynamic_cast(iter); if (child) @@ -116,7 +116,7 @@ void PUDoEnableComponentEventHandler::handle(PUParticleSystem3D* particleSystem, if (system) { auto children = system->getChildren(); - for (auto iter : children) + for (auto&& iter : children) { PUParticleSystem3D* child = dynamic_cast(iter); if (child) @@ -144,7 +144,7 @@ void PUDoEnableComponentEventHandler::handle(PUParticleSystem3D* particleSystem, if (system) { auto children = system->getChildren(); - for (auto iter : children) + for (auto&& iter : children) { PUParticleSystem3D* child = dynamic_cast(iter); if (child && child->getName() == _componentName) diff --git a/extensions/Particle3D/PU/CCPUDoPlacementParticleEventHandler.cpp b/extensions/Particle3D/PU/CCPUDoPlacementParticleEventHandler.cpp index 2c71d7156c..b03f5d408b 100644 --- a/extensions/Particle3D/PU/CCPUDoPlacementParticleEventHandler.cpp +++ b/extensions/Particle3D/PU/CCPUDoPlacementParticleEventHandler.cpp @@ -81,7 +81,7 @@ void PUDoPlacementParticleEventHandler::handle(PUParticleSystem3D* particleSyste if (parentSystem) { auto children = parentSystem->getChildren(); - for (auto iter : children) + for (auto&& iter : children) { PUParticleSystem3D* child = dynamic_cast(iter); if (child) diff --git a/extensions/Particle3D/PU/CCPUEmitter.cpp b/extensions/Particle3D/PU/CCPUEmitter.cpp index 297febaf67..9ca8c947e0 100644 --- a/extensions/Particle3D/PU/CCPUEmitter.cpp +++ b/extensions/Particle3D/PU/CCPUEmitter.cpp @@ -378,7 +378,7 @@ void PUEmitter::prepare() if (system) { auto children = system->getChildren(); - for (auto it : children) + for (auto&& it : children) { if (it->getName() == _emitsName) { diff --git a/extensions/Particle3D/PU/CCPUFlockCenteringAffector.cpp b/extensions/Particle3D/PU/CCPUFlockCenteringAffector.cpp index 8579745c07..c2d4cc9075 100644 --- a/extensions/Particle3D/PU/CCPUFlockCenteringAffector.cpp +++ b/extensions/Particle3D/PU/CCPUFlockCenteringAffector.cpp @@ -35,7 +35,7 @@ PUFlockCenteringAffector::~PUFlockCenteringAffector() {} void PUFlockCenteringAffector::updatePUAffector(PUParticle3D* particle, float deltaTime) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; _sum += particle->position; diff --git a/extensions/Particle3D/PU/CCPUForceFieldAffector.cpp b/extensions/Particle3D/PU/CCPUForceFieldAffector.cpp index a65639fa22..82119389fe 100644 --- a/extensions/Particle3D/PU/CCPUForceFieldAffector.cpp +++ b/extensions/Particle3D/PU/CCPUForceFieldAffector.cpp @@ -242,7 +242,7 @@ void PUForceFieldAffector::suppressGeneration(bool suppress) void PUForceFieldAffector::updatePUAffector(PUParticle3D* particle, float deltaTime) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; _forceField.determineForce(particle->position, _force, _delta); diff --git a/extensions/Particle3D/PU/CCPUGeometryRotator.cpp b/extensions/Particle3D/PU/CCPUGeometryRotator.cpp index 40e7407490..96393db53e 100644 --- a/extensions/Particle3D/PU/CCPUGeometryRotator.cpp +++ b/extensions/Particle3D/PU/CCPUGeometryRotator.cpp @@ -104,7 +104,7 @@ void PUGeometryRotator::initParticleForEmission(PUParticle3D* particle) //// Only continue if the particle is a visual particle // if (particle->particleType != Particle::PT_VISUAL) // return; - // for (auto iter : _particleSystem->getParticlePool().getActiveParticleList()) + // for (auto&& iter : _particleSystem->getParticlePool().getActiveParticleList()) { // PUParticle3D *particle = static_cast(iter); if (!_rotationAxisSet) @@ -132,7 +132,7 @@ void PUGeometryRotator::initParticleForEmission(PUParticle3D* particle) void PUGeometryRotator::updatePUAffector(PUParticle3D* particle, float deltaTime) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; // Rotate the geometry diff --git a/extensions/Particle3D/PU/CCPUGravityAffector.cpp b/extensions/Particle3D/PU/CCPUGravityAffector.cpp index fc05156ecc..eae725a580 100644 --- a/extensions/Particle3D/PU/CCPUGravityAffector.cpp +++ b/extensions/Particle3D/PU/CCPUGravityAffector.cpp @@ -49,7 +49,7 @@ void PUGravityAffector::setGravity(float gravity) void PUGravityAffector::updatePUAffector(PUParticle3D* particle, float deltaTime) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; // Applied scaling in V1.3.1 diff --git a/extensions/Particle3D/PU/CCPUInterParticleCollider.cpp b/extensions/Particle3D/PU/CCPUInterParticleCollider.cpp index 934a38f411..e9814e3a73 100644 --- a/extensions/Particle3D/PU/CCPUInterParticleCollider.cpp +++ b/extensions/Particle3D/PU/CCPUInterParticleCollider.cpp @@ -131,7 +131,7 @@ bool PUParticle3DInterParticleCollider::validateAndExecuteSphereCollision(PUPart void PUParticle3DInterParticleCollider::updatePUAffector(PUParticle3D* /*particle*/, float /*deltaTime*/) { // AXASSERT(0, "nonsupport yet"); - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) //{ // PUParticle3D *particle = iter; // Fast rejection: only visible, moving particles are able to collide, unless they are colliding already diff --git a/extensions/Particle3D/PU/CCPUJetAffector.cpp b/extensions/Particle3D/PU/CCPUJetAffector.cpp index f5d428375f..6bb29b94e3 100644 --- a/extensions/Particle3D/PU/CCPUJetAffector.cpp +++ b/extensions/Particle3D/PU/CCPUJetAffector.cpp @@ -58,7 +58,7 @@ void PUJetAffector::setDynAcceleration(PUDynamicAttribute* dynAcceleration) void PUJetAffector::updatePUAffector(PUParticle3D* particle, float deltaTime) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; _scaled = deltaTime * (_dynAcceleration->getValue(particle->timeFraction)); diff --git a/extensions/Particle3D/PU/CCPULineAffector.cpp b/extensions/Particle3D/PU/CCPULineAffector.cpp index 99c5094cd7..2730b1ade2 100644 --- a/extensions/Particle3D/PU/CCPULineAffector.cpp +++ b/extensions/Particle3D/PU/CCPULineAffector.cpp @@ -117,7 +117,7 @@ void PULineAffector::preUpdateAffector(float deltaTime) void PULineAffector::updatePUAffector(PUParticle3D* particle, float /*deltaTime*/) { //_first = true; - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; (static_cast(_particleSystem)) diff --git a/extensions/Particle3D/PU/CCPULinearForceAffector.cpp b/extensions/Particle3D/PU/CCPULinearForceAffector.cpp index 1e82131f5a..d366dad04e 100644 --- a/extensions/Particle3D/PU/CCPULinearForceAffector.cpp +++ b/extensions/Particle3D/PU/CCPULinearForceAffector.cpp @@ -39,7 +39,7 @@ void PULinearForceAffector::preUpdateAffector(float deltaTime) void PULinearForceAffector::updatePUAffector(PUParticle3D* particle, float /*deltaTime*/) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; // Affect the direction and take the specialisation into account diff --git a/extensions/Particle3D/PU/CCPUMaterialManager.cpp b/extensions/Particle3D/PU/CCPUMaterialManager.cpp index 217a167339..8f2d17134e 100644 --- a/extensions/Particle3D/PU/CCPUMaterialManager.cpp +++ b/extensions/Particle3D/PU/CCPUMaterialManager.cpp @@ -64,7 +64,7 @@ PUMaterialCache::PUMaterialCache() {} PUMaterialCache::~PUMaterialCache() { - for (auto iter : _materialMap) + for (auto&& iter : _materialMap) { iter->release(); } @@ -79,7 +79,7 @@ PUMaterialCache* PUMaterialCache::Instance() PUMaterial* PUMaterialCache::getMaterial(std::string_view name) { - for (auto iter : _materialMap) + for (auto&& iter : _materialMap) { if (iter->name == name) return iter; @@ -102,7 +102,7 @@ bool PUMaterialCache::loadMaterials(std::string_view file) void PUMaterialCache::addMaterial(PUMaterial* material) { - for (auto iter : _materialMap) + for (auto&& iter : _materialMap) { if (iter->name == material->name) { diff --git a/extensions/Particle3D/PU/CCPUParticleFollower.cpp b/extensions/Particle3D/PU/CCPUParticleFollower.cpp index 342d58133f..47de664584 100644 --- a/extensions/Particle3D/PU/CCPUParticleFollower.cpp +++ b/extensions/Particle3D/PU/CCPUParticleFollower.cpp @@ -63,7 +63,7 @@ void PUParticleFollower::setMinDistance(float minDistance) void PUParticleFollower::updatePUAffector(PUParticle3D* particle, float /*deltaTime*/) { //_first = true; - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; if (!_first) diff --git a/extensions/Particle3D/PU/CCPUParticleSystem3D.cpp b/extensions/Particle3D/PU/CCPUParticleSystem3D.cpp index 77e95f3e03..fef252e586 100644 --- a/extensions/Particle3D/PU/CCPUParticleSystem3D.cpp +++ b/extensions/Particle3D/PU/CCPUParticleSystem3D.cpp @@ -90,7 +90,7 @@ void PUParticle3D::initForEmission() if (!behaviours.empty()) { - for (auto& it : behaviours) + for (auto&& it : behaviours) { it->initParticleForEmission(this); } @@ -101,7 +101,7 @@ void PUParticle3D::initForExpiration(float timeElapsed) { if (!behaviours.empty()) { - for (auto& it : behaviours) + for (auto&& it : behaviours) { it->initParticleForExpiration(this, timeElapsed); } @@ -114,7 +114,7 @@ void PUParticle3D::process(float timeElapsed) if (!behaviours.empty()) { - for (auto& it : behaviours) + for (auto&& it : behaviours) { it->updateBehaviour(this, timeElapsed); } @@ -158,7 +158,7 @@ PUParticle3D::PUParticle3D() PUParticle3D::~PUParticle3D() { - for (auto it : behaviours) + for (auto&& it : behaviours) { it->release(); } @@ -168,7 +168,7 @@ PUParticle3D::~PUParticle3D() void PUParticle3D::copyBehaviours(const ParticleBehaviourList& list) { - for (auto it : list) + for (auto&& it : list) { auto behaviour = it->clone(); behaviour->retain(); @@ -210,22 +210,22 @@ PUParticleSystem3D::~PUParticleSystem3D() _particlePool.removeAllDatas(); - for (auto iter : _emittedEmitterParticlePool) + for (auto&& iter : _emittedEmitterParticlePool) { auto pool = iter.second; auto lockedList = pool.getUnActiveDataList(); - for (auto iter2 : lockedList) + for (auto&& iter2 : lockedList) { static_cast(iter2)->particleEntityPtr->release(); } iter.second.removeAllDatas(); } - for (auto iter : _emittedSystemParticlePool) + for (auto&& iter : _emittedSystemParticlePool) { auto pool = iter.second; auto lockedList = pool.getUnActiveDataList(); - for (auto iter2 : lockedList) + for (auto&& iter2 : lockedList) { static_cast(iter2)->particleEntityPtr->release(); } @@ -233,18 +233,18 @@ PUParticleSystem3D::~PUParticleSystem3D() } // release all emitters - for (auto it : _emitters) + for (auto&& it : _emitters) { it->release(); } _emitters.clear(); - for (auto it : _observers) + for (auto&& it : _observers) { it->release(); } - for (auto it : _behaviourTemplates) + for (auto&& it : _behaviourTemplates) { it->release(); } @@ -342,18 +342,18 @@ void PUParticleSystem3D::startParticleSystem() if (_render) _render->notifyStart(); - for (auto& it : _observers) + for (auto&& it : _observers) { it->notifyStart(); } - for (auto& it : _emitters) + for (auto&& it : _emitters) { auto emitter = static_cast(it); emitter->notifyStart(); } - for (auto& it : _affectors) + for (auto&& it : _affectors) { auto affector = static_cast(it); affector->notifyStart(); @@ -363,7 +363,7 @@ void PUParticleSystem3D::startParticleSystem() _state = State::RUNNING; } - for (auto iter : _children) + for (auto&& iter : _children) { PUParticleSystem3D* system = dynamic_cast(iter); if (system) @@ -381,7 +381,7 @@ void PUParticleSystem3D::stopParticleSystem() _state = State::STOP; } - for (auto iter : _children) + for (auto&& iter : _children) { PUParticleSystem3D* system = dynamic_cast(iter); if (system) @@ -399,13 +399,13 @@ void PUParticleSystem3D::pauseParticleSystem() // emitter->notifyPause(); // } - for (auto& it : _emitters) + for (auto&& it : _emitters) { auto emitter = static_cast(it); emitter->notifyPause(); } - for (auto& it : _affectors) + for (auto&& it : _affectors) { auto affector = static_cast(it); affector->notifyPause(); @@ -414,7 +414,7 @@ void PUParticleSystem3D::pauseParticleSystem() _state = State::PAUSE; } - for (auto iter : _children) + for (auto&& iter : _children) { PUParticleSystem3D* system = dynamic_cast(iter); if (system) @@ -432,13 +432,13 @@ void PUParticleSystem3D::resumeParticleSystem() // emitter->notifyResume(); // } - for (auto& it : _emitters) + for (auto&& it : _emitters) { auto emitter = static_cast(it); emitter->notifyResume(); } - for (auto& it : _affectors) + for (auto&& it : _affectors) { auto affector = static_cast(it); affector->notifyResume(); @@ -447,7 +447,7 @@ void PUParticleSystem3D::resumeParticleSystem() _state = State::RUNNING; } - for (auto iter : _children) + for (auto&& iter : _children) { PUParticleSystem3D* system = dynamic_cast(iter); if (system) @@ -521,18 +521,18 @@ void PUParticleSystem3D::prepared() if (_render) static_cast(_render)->prepare(); - for (auto it : _behaviourTemplates) + for (auto&& it : _behaviourTemplates) { it->prepare(); } - for (auto it : _emitters) + for (auto&& it : _emitters) { // if (it->isEnabled()) (static_cast(it))->prepare(); } - for (auto it : _affectors) + for (auto&& it : _affectors) { // if (it->isEnabled()) (static_cast(it))->prepare(); @@ -540,7 +540,7 @@ void PUParticleSystem3D::prepared() if (!_poolPrepared) { - for (auto it : _emitters) + for (auto&& it : _emitters) { // if (it->isEnabled()) PUEmitter* emitter = static_cast(it); @@ -609,25 +609,25 @@ void PUParticleSystem3D::unPrepared() if (_render) static_cast(_render)->unPrepare(); - for (auto it : _behaviourTemplates) + for (auto&& it : _behaviourTemplates) { it->unPrepare(); } - for (auto it : _emitters) + for (auto&& it : _emitters) { if (it->isEnabled()) (static_cast(it))->unPrepare(); } - for (auto it : _affectors) + for (auto&& it : _affectors) { if (it->isEnabled()) (static_cast(it))->unPrepare(); } _particlePool.lockAllDatas(); - for (auto& iter : _emittedEmitterParticlePool) + for (auto&& iter : _emittedEmitterParticlePool) { PUParticle3D* particle = static_cast(const_cast(iter.second).getFirst()); while (particle) @@ -638,7 +638,7 @@ void PUParticleSystem3D::unPrepared() const_cast(iter.second).lockAllDatas(); } - for (auto& iter : _emittedSystemParticlePool) + for (auto&& iter : _emittedSystemParticlePool) { PUParticle3D* particle = static_cast(const_cast(iter.second).getFirst()); while (particle) @@ -660,7 +660,7 @@ void PUParticleSystem3D::preUpdator(float elapsedTime) // emitter->preUpdateEmitter(elapsedTime); // } // bool hasNoEmitted = true; - for (auto it : _emitters) + for (auto&& it : _emitters) { if (!it->isEmitterDone()) { @@ -674,7 +674,7 @@ void PUParticleSystem3D::preUpdator(float elapsedTime) // stopParticle(); // } - for (auto it : _affectors) + for (auto&& it : _affectors) { if (it->isEnabled()) { @@ -682,7 +682,7 @@ void PUParticleSystem3D::preUpdator(float elapsedTime) } } - for (auto it : _observers) + for (auto&& it : _observers) { if (it->isEnabled()) { @@ -690,7 +690,7 @@ void PUParticleSystem3D::preUpdator(float elapsedTime) } } - for (auto& iter : _emittedEmitterParticlePool) + for (auto&& iter : _emittedEmitterParticlePool) { PUParticle3D* particle = static_cast(const_cast(iter.second).getFirst()); while (particle) @@ -700,7 +700,7 @@ void PUParticleSystem3D::preUpdator(float elapsedTime) } } - for (auto& iter : _emittedSystemParticlePool) + for (auto&& iter : _emittedSystemParticlePool) { PUParticle3D* particle = static_cast(const_cast(iter.second).getFirst()); while (particle) @@ -717,12 +717,12 @@ void PUParticleSystem3D::updator(float elapsedTime) bool firstParticle = true; processParticle(_particlePool, firstActiveParticle, firstParticle, elapsedTime); - for (auto& iter : _emittedEmitterParticlePool) + for (auto&& iter : _emittedEmitterParticlePool) { processParticle(const_cast(iter.second), firstActiveParticle, firstParticle, elapsedTime); } - for (auto& iter : _emittedSystemParticlePool) + for (auto&& iter : _emittedSystemParticlePool) { processParticle(const_cast(iter.second), firstActiveParticle, firstParticle, elapsedTime); } @@ -736,7 +736,7 @@ void PUParticleSystem3D::postUpdator(float elapsedTime) // emitter->postUpdateEmitter(elapsedTime); // } - for (auto it : _emitters) + for (auto&& it : _emitters) { if (it->isEnabled()) { @@ -744,7 +744,7 @@ void PUParticleSystem3D::postUpdator(float elapsedTime) } } - for (auto it : _affectors) + for (auto&& it : _affectors) { if (it->isEnabled()) { @@ -753,7 +753,7 @@ void PUParticleSystem3D::postUpdator(float elapsedTime) } } - for (auto it : _observers) + for (auto&& it : _observers) { if (it->isEnabled()) { @@ -761,7 +761,7 @@ void PUParticleSystem3D::postUpdator(float elapsedTime) } } - for (auto& iter : _emittedEmitterParticlePool) + for (auto&& iter : _emittedEmitterParticlePool) { PUParticle3D* particle = static_cast(const_cast(iter.second).getFirst()); while (particle) @@ -771,7 +771,7 @@ void PUParticleSystem3D::postUpdator(float elapsedTime) } } - for (auto& iter : _emittedSystemParticlePool) + for (auto&& iter : _emittedSystemParticlePool) { PUParticle3D* particle = static_cast(const_cast(iter.second).getFirst()); while (particle) @@ -785,7 +785,7 @@ void PUParticleSystem3D::postUpdator(float elapsedTime) void PUParticleSystem3D::emitParticles(float elapsedTime) { // Vec3 scale = getDerivedScale(); - for (auto iter : _emitters) + for (auto&& iter : _emitters) { // if (!_emitter) return; // auto emitter = static_cast(_emitter); @@ -924,7 +924,7 @@ void PUParticleSystem3D::addEmitter(PUEmitter* emitter) PUAffector* PUParticleSystem3D::getAffector(std::string_view name) { - for (auto iter : _affectors) + for (auto&& iter : _affectors) { auto pa = static_cast(iter); if (pa->getName() == name) @@ -936,7 +936,7 @@ PUAffector* PUParticleSystem3D::getAffector(std::string_view name) PUEmitter* PUParticleSystem3D::getEmitter(std::string_view name) { - for (auto iter : _emitters) + for (auto&& iter : _emitters) { auto pe = static_cast(iter); if (pe->getName() == name) @@ -1011,7 +1011,7 @@ void PUParticleSystem3D::emitParticles(ParticlePool& pool, PUEmitter* emitter, u particle->originalDirection = (rotMat * Vec3(particle->originalDirection.x, particle->originalDirection.y, particle->originalDirection.z)); - for (auto& it : _affectors) + for (auto&& it : _affectors) { if (it->isEnabled()) { @@ -1042,7 +1042,7 @@ void PUParticleSystem3D::addObserver(PUObserver* observer) PUObserver* PUParticleSystem3D::getObserver(std::string_view name) { - for (auto iter : _observers) + for (auto&& iter : _observers) { auto po = static_cast(iter); if (po->getName() == name) @@ -1057,22 +1057,22 @@ void PUParticleSystem3D::notifyRescaled(const Vec3& scl) if (_render) _render->notifyRescaled(scl); - for (auto it : _emitters) + for (auto&& it : _emitters) { (static_cast(it))->notifyRescaled(scl); } - for (auto it : _affectors) + for (auto&& it : _affectors) { (static_cast(it))->notifyRescaled(scl); } - for (auto it : _observers) + for (auto&& it : _observers) { it->notifyRescaled(scl); } - for (auto& iter : _emittedEmitterParticlePool) + for (auto&& iter : _emittedEmitterParticlePool) { PUParticle3D* particle = static_cast(const_cast(iter.second).getFirst()); while (particle) @@ -1082,7 +1082,7 @@ void PUParticleSystem3D::notifyRescaled(const Vec3& scl) } } - for (auto& iter : _emittedSystemParticlePool) + for (auto&& iter : _emittedSystemParticlePool) { PUParticle3D* particle = static_cast(const_cast(iter.second).getFirst()); while (particle) @@ -1108,7 +1108,7 @@ void PUParticleSystem3D::initParticleForExpiration(PUParticle3D* particle, float particle->initForExpiration(timeElapsed); - for (auto it : _listeners) + for (auto&& it : _listeners) { it->particleExpired(this, particle); } @@ -1129,7 +1129,7 @@ void PUParticleSystem3D::initParticleForExpiration(PUParticle3D* particle, float void PUParticleSystem3D::initParticleForEmission(PUParticle3D* particle) { - for (auto it : _listeners) + for (auto&& it : _listeners) { it->particleEmitted(this, particle); } @@ -1149,7 +1149,7 @@ void PUParticleSystem3D::addBehaviourTemplate(PUBehaviour* behaviour) void PUParticleSystem3D::convertToUnixStylePath(std::string& path) { #if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) - for (auto& iter : path) + for (auto&& iter : path) { if (iter == '\\') iter = '/'; @@ -1162,12 +1162,12 @@ void PUParticleSystem3D::convertToUnixStylePath(std::string& path) void PUParticleSystem3D::clearAllParticles() { _particlePool.lockAllDatas(); - for (auto& iter : _emittedEmitterParticlePool) + for (auto&& iter : _emittedEmitterParticlePool) { const_cast(iter.second).lockAllDatas(); } - for (auto& iter : _emittedSystemParticlePool) + for (auto&& iter : _emittedSystemParticlePool) { const_cast(iter.second).lockAllDatas(); } @@ -1181,12 +1181,12 @@ void PUParticleSystem3D::copyAttributesTo(PUParticleSystem3D* system) system->removeAllBehaviourTemplate(); system->removeAllListener(); system->_particlePool.removeAllDatas(); - for (auto iter : system->_emittedEmitterParticlePool) + for (auto&& iter : system->_emittedEmitterParticlePool) { iter.second.removeAllDatas(); } - for (auto iter : system->_emittedSystemParticlePool) + for (auto&& iter : system->_emittedSystemParticlePool) { iter.second.removeAllDatas(); } @@ -1200,7 +1200,7 @@ void PUParticleSystem3D::copyAttributesTo(PUParticleSystem3D* system) system->_keepLocal = _keepLocal; system->_isEnabled = _isEnabled; - for (auto iter : _affectors) + for (auto&& iter : _affectors) { PUAffector* affector = static_cast(iter); PUAffector* copy = PUAffectorManager::Instance()->createAffector(affector->getAffectorType()); @@ -1208,7 +1208,7 @@ void PUParticleSystem3D::copyAttributesTo(PUParticleSystem3D* system) system->addAffector(copy); } - for (auto iter : _emitters) + for (auto&& iter : _emitters) { PUEmitter* emitter = static_cast(iter); PUEmitter* copy = PUEmitterManager::Instance()->createEmitter(emitter->getEmitterType()); @@ -1216,7 +1216,7 @@ void PUParticleSystem3D::copyAttributesTo(PUParticleSystem3D* system) system->addEmitter(copy); } - for (auto iter : _observers) + for (auto&& iter : _observers) { PUObserver* observer = static_cast(iter); PUObserver* copy = PUObserverManager::Instance()->createObserver(observer->getObserverType()); @@ -1224,7 +1224,7 @@ void PUParticleSystem3D::copyAttributesTo(PUParticleSystem3D* system) system->addObserver(copy); } - for (auto iter : _behaviourTemplates) + for (auto&& iter : _behaviourTemplates) { PUBehaviour* behaviour = static_cast(iter); PUBehaviour* copy = behaviour->clone(); @@ -1249,7 +1249,7 @@ PUParticleSystem3D* PUParticleSystem3D::clone() { auto ps = PUParticleSystem3D::create(); copyAttributesTo(ps); - for (auto& iter : _children) + for (auto&& iter : _children) { PUParticleSystem3D* child = dynamic_cast(iter); if (child) @@ -1260,7 +1260,7 @@ PUParticleSystem3D* PUParticleSystem3D::clone() void PUParticleSystem3D::removeAllEmitter() { - for (auto iter : _emitters) + for (auto&& iter : _emitters) { iter->release(); } @@ -1269,7 +1269,7 @@ void PUParticleSystem3D::removeAllEmitter() void PUParticleSystem3D::removerAllObserver() { - for (auto iter : _observers) + for (auto&& iter : _observers) { iter->release(); } @@ -1278,7 +1278,7 @@ void PUParticleSystem3D::removerAllObserver() void PUParticleSystem3D::removeAllBehaviourTemplate() { - for (auto iter : _behaviourTemplates) + for (auto&& iter : _behaviourTemplates) { iter->release(); } @@ -1301,7 +1301,7 @@ void PUParticleSystem3D::draw(Renderer* renderer, const Mat4& transform, uint32_ if (!_emittedSystemParticlePool.empty()) { - for (auto& iter : _emittedSystemParticlePool) + for (auto&& iter : _emittedSystemParticlePool) { PUParticle3D* particle = static_cast(const_cast(iter.second).getFirst()); while (particle) @@ -1334,7 +1334,7 @@ void PUParticleSystem3D::processParticle(ParticlePool& pool, // if (_emitter && _emitter->isEnabled()) // _emitter->updateEmitter(particle, elapsedTime); - for (auto it : _emitters) + for (auto&& it : _emitters) { if (it->isEnabled() && !it->isMarkedForEmission()) { @@ -1342,7 +1342,7 @@ void PUParticleSystem3D::processParticle(ParticlePool& pool, } } - for (auto& it : _affectors) + for (auto&& it : _affectors) { if (it->isEnabled()) { @@ -1409,7 +1409,7 @@ void PUParticleSystem3D::processParticle(ParticlePool& pool, pool.lockLatestData(); } - for (auto it : _observers) + for (auto&& it : _observers) { if (it->isEnabled()) { @@ -1529,7 +1529,7 @@ int PUParticleSystem3D::getAliveParticleCount() const if (!_emittedEmitterParticlePool.empty()) { - for (auto& iter : _emittedEmitterParticlePool) + for (auto&& iter : _emittedEmitterParticlePool) { sz += iter.second.getActiveDataList().size(); } @@ -1538,7 +1538,7 @@ int PUParticleSystem3D::getAliveParticleCount() const if (_emittedSystemParticlePool.empty()) return sz; - for (auto& iter : _emittedSystemParticlePool) + for (auto&& iter : _emittedSystemParticlePool) { auto pool = iter.second; sz += pool.getActiveDataList().size(); @@ -1557,18 +1557,18 @@ void PUParticleSystem3D::forceStopParticleSystem() if (_render) _render->notifyStop(); - for (auto& it : _observers) + for (auto&& it : _observers) { it->notifyStop(); } - for (auto& it : _emitters) + for (auto&& it : _emitters) { auto emitter = static_cast(it); emitter->notifyStop(); } - for (auto& it : _affectors) + for (auto&& it : _affectors) { auto affector = static_cast(it); affector->notifyStop(); diff --git a/extensions/Particle3D/PU/CCPUPathFollower.cpp b/extensions/Particle3D/PU/CCPUPathFollower.cpp index 1b6e8a014a..ffbcb79c87 100644 --- a/extensions/Particle3D/PU/CCPUPathFollower.cpp +++ b/extensions/Particle3D/PU/CCPUPathFollower.cpp @@ -47,7 +47,7 @@ void PUPathFollower::clearPoints() void PUPathFollower::updatePUAffector(PUParticle3D* particle, float deltaTime) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; if (_spline.getNumPoints() > 0) diff --git a/extensions/Particle3D/PU/CCPUPlaneCollider.cpp b/extensions/Particle3D/PU/CCPUPlaneCollider.cpp index 91afc83c71..60044876c5 100644 --- a/extensions/Particle3D/PU/CCPUPlaneCollider.cpp +++ b/extensions/Particle3D/PU/CCPUPlaneCollider.cpp @@ -90,7 +90,7 @@ void PUPlaneCollider::calculateDirectionAfterCollision(PUParticle3D* particle, f void PUPlaneCollider::updatePUAffector(PUParticle3D* particle, float deltaTime) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; _predictedPosition = particle->position + _velocityScale * particle->direction; diff --git a/extensions/Particle3D/PU/CCPURandomiser.cpp b/extensions/Particle3D/PU/CCPURandomiser.cpp index 829df83a16..f75f91887b 100644 --- a/extensions/Particle3D/PU/CCPURandomiser.cpp +++ b/extensions/Particle3D/PU/CCPURandomiser.cpp @@ -114,7 +114,7 @@ void PURandomiser::preUpdateAffector(float deltaTime) //----------------------------------------------------------------------- void PURandomiser::updatePUAffector(PUParticle3D* particle, float /*deltaTime*/) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; if (_update) diff --git a/extensions/Particle3D/PU/CCPURender.cpp b/extensions/Particle3D/PU/CCPURender.cpp index 0d440e95e0..ad0263241c 100644 --- a/extensions/Particle3D/PU/CCPURender.cpp +++ b/extensions/Particle3D/PU/CCPURender.cpp @@ -112,7 +112,7 @@ void PUParticle3DQuadRender::render(Renderer* renderer, const Mat4& transform, P auto camera = Camera::getVisitingCamera(); auto cameraMat = camera->getNodeToWorldTransform(); - // for (auto iter : activeParticleList){ + // for (auto&& iter : activeParticleList){ // iter->depthInView = -(viewMat.m[2] * iter->positionInWorld.x + viewMat.m[6] * iter->positionInWorld.y + // viewMat.m[10] * iter->positionInWorld.z + viewMat.m[14]); // } @@ -145,7 +145,7 @@ void PUParticle3DQuadRender::render(Renderer* renderer, const Mat4& transform, P right.normalize(); } - for (auto iter : activeParticleList) + for (auto&& iter : activeParticleList) { auto particle = static_cast(iter); determineUVCoords(particle); @@ -539,7 +539,7 @@ void PUParticle3DModelRender::render(Renderer* renderer, const Mat4& transform, Quaternion q; transform.decompose(nullptr, &q, nullptr); unsigned int index = 0; - for (auto iter : activeParticleList) + for (auto&& iter : activeParticleList) { auto particle = static_cast(iter); Mat4::createRotation(q * particle->orientation, &rotMat); @@ -567,7 +567,7 @@ PUParticle3DModelRender::PUParticle3DModelRender() PUParticle3DModelRender::~PUParticle3DModelRender() { - for (auto iter : _meshList) + for (auto&& iter : _meshList) { iter->release(); } @@ -587,7 +587,7 @@ PUParticle3DModelRender* PUParticle3DModelRender::clone() void PUParticle3DModelRender::reset() { - for (auto iter : _meshList) + for (auto&& iter : _meshList) { iter->release(); } @@ -746,7 +746,7 @@ void PUParticle3DBoxRender::render(Renderer* renderer, const Mat4& transform, Pa unsigned int index = 0; Mat4 texRot; Vec3 val; - for (auto iter : particlePool.getActiveDataList()) + for (auto&& iter : particlePool.getActiveDataList()) { auto particle = static_cast(iter); float halfHeight = particle->height * 0.5f; @@ -943,7 +943,7 @@ void PUSphereRender::render(Renderer* renderer, const Mat4& transform, ParticleS Mat4 sclMat; Mat4 texRot; Vec3 val; - for (auto iter : particlePool.getActiveDataList()) + for (auto&& iter : particlePool.getActiveDataList()) { auto particle = static_cast(iter); float radius = particle->width * 0.5f; diff --git a/extensions/Particle3D/PU/CCPURibbonTrail.cpp b/extensions/Particle3D/PU/CCPURibbonTrail.cpp index fe3c518fc0..f128805853 100644 --- a/extensions/Particle3D/PU/CCPURibbonTrail.cpp +++ b/extensions/Particle3D/PU/CCPURibbonTrail.cpp @@ -413,7 +413,7 @@ void PURibbonTrail::update(float deltaTime) lastUpdateTime += deltaTime; } - for (auto iter : _nodeToSegMap) + for (auto&& iter : _nodeToSegMap) { updateTrail(iter.second, iter.first); } diff --git a/extensions/Particle3D/PU/CCPURibbonTrailRender.cpp b/extensions/Particle3D/PU/CCPURibbonTrailRender.cpp index f70fb6d37f..9a59a76d28 100644 --- a/extensions/Particle3D/PU/CCPURibbonTrailRender.cpp +++ b/extensions/Particle3D/PU/CCPURibbonTrailRender.cpp @@ -393,7 +393,7 @@ void PURibbonTrailRender::copyAttributesTo(PURibbonTrailRender* trailRender) void PURibbonTrailRender::updateParticles(const ParticlePool& pool) { PURibbonTrailVisualData* visualData = nullptr; - for (auto iter : pool.getActiveDataList()) + for (auto&& iter : pool.getActiveDataList()) { auto particle = static_cast(iter); if (!particle->visualData && !_visualData.empty()) diff --git a/extensions/Particle3D/PU/CCPUScaleAffector.cpp b/extensions/Particle3D/PU/CCPUScaleAffector.cpp index 5e387c31ae..da0f449b18 100644 --- a/extensions/Particle3D/PU/CCPUScaleAffector.cpp +++ b/extensions/Particle3D/PU/CCPUScaleAffector.cpp @@ -198,7 +198,7 @@ void PUScaleAffector::updatePUAffector(PUParticle3D* particle, float deltaTime) //// Only continue if the particle is a visual particle // if (particle->particleType != Particle::PT_VISUAL) // return; - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; float ds = 0; diff --git a/extensions/Particle3D/PU/CCPUScaleVelocityAffector.cpp b/extensions/Particle3D/PU/CCPUScaleVelocityAffector.cpp index 7d192ac6d5..feaadc31ea 100644 --- a/extensions/Particle3D/PU/CCPUScaleVelocityAffector.cpp +++ b/extensions/Particle3D/PU/CCPUScaleVelocityAffector.cpp @@ -48,7 +48,7 @@ PUScaleVelocityAffector::~PUScaleVelocityAffector() //----------------------------------------------------------------------- void PUScaleVelocityAffector::updatePUAffector(PUParticle3D* particle, float deltaTime) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; float ds = 0; diff --git a/extensions/Particle3D/PU/CCPUScriptCompiler.cpp b/extensions/Particle3D/PU/CCPUScriptCompiler.cpp index 84a33fc647..052d4a60e4 100644 --- a/extensions/Particle3D/PU/CCPUScriptCompiler.cpp +++ b/extensions/Particle3D/PU/CCPUScriptCompiler.cpp @@ -102,17 +102,17 @@ const hlookup::string_map& PUObjectAbstractNode::getVariables() con PUObjectAbstractNode::~PUObjectAbstractNode() { - for (auto iter : children) + for (auto&& iter : children) { delete iter; } - for (auto iter : values) + for (auto&& iter : values) { delete iter; } - for (auto iter : overrides) + for (auto&& iter : overrides) { delete iter; } @@ -148,7 +148,7 @@ std::string PUPropertyAbstractNode::getValue() const PUPropertyAbstractNode::~PUPropertyAbstractNode() { - for (auto iter : values) + for (auto&& iter : values) { delete iter; } @@ -180,7 +180,7 @@ PUScriptCompiler::~PUScriptCompiler() { for (const auto& iter : _compiledScripts) { - for (auto miter : iter.second) + for (auto&& miter : iter.second) { delete miter; } @@ -211,7 +211,7 @@ hlookup::string_map::iterator PUScriptCompiler::compile(cons // } // } - // for (auto iter : aNodes){ + // for (auto&& iter : aNodes){ // delete iter; // } // return true; @@ -235,12 +235,12 @@ const PUAbstractNodeList* PUScriptCompiler::compile(std::string_view file, bool& parser.parse(creteNodeList, tokenList); auto it = compile(creteNodeList, file); - for (auto iter1 : creteNodeList) + for (auto&& iter1 : creteNodeList) { delete iter1; } - for (auto iter2 : tokenList) + for (auto&& iter2 : tokenList) { delete iter2; } diff --git a/extensions/Particle3D/PU/CCPUScriptParser.cpp b/extensions/Particle3D/PU/CCPUScriptParser.cpp index f6c962e991..30aa5121da 100644 --- a/extensions/Particle3D/PU/CCPUScriptParser.cpp +++ b/extensions/Particle3D/PU/CCPUScriptParser.cpp @@ -523,7 +523,7 @@ PUScriptTokenList::const_iterator PUScriptParser::skipNewlines(PUScriptTokenList PUConcreteNode::~PUConcreteNode() { - for (auto iter : children) + for (auto&& iter : children) { delete iter; } diff --git a/extensions/Particle3D/PU/CCPUSineForceAffector.cpp b/extensions/Particle3D/PU/CCPUSineForceAffector.cpp index e492c23a30..1c2e4eeaa9 100644 --- a/extensions/Particle3D/PU/CCPUSineForceAffector.cpp +++ b/extensions/Particle3D/PU/CCPUSineForceAffector.cpp @@ -88,7 +88,7 @@ void PUSineForceAffector::setFrequencyMax(const float frequencyMax) void PUSineForceAffector::updatePUAffector(PUParticle3D* particle, float /*deltaTime*/) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; // Affect the direction diff --git a/extensions/Particle3D/PU/CCPUSlaveEmitter.cpp b/extensions/Particle3D/PU/CCPUSlaveEmitter.cpp index f251ce2b5a..b7c2ea7d26 100644 --- a/extensions/Particle3D/PU/CCPUSlaveEmitter.cpp +++ b/extensions/Particle3D/PU/CCPUSlaveEmitter.cpp @@ -100,7 +100,7 @@ void PUSlaveEmitter::initParticleDirection(PUParticle3D* particle) // Make use of the opportunity to set the master particle in the behaviour object (if available) - for (auto iter : particle->behaviours) + for (auto&& iter : particle->behaviours) { if (iter->getBehaviourType() == "Slave") { @@ -116,7 +116,7 @@ void PUSlaveEmitter::prepare() if (system) { auto children = system->getChildren(); - for (auto it : children) + for (auto&& it : children) { if (it->getName() == _masterTechniqueName) { @@ -136,7 +136,7 @@ void PUSlaveEmitter::unPrepare() if (system) { auto children = system->getChildren(); - for (auto it : children) + for (auto&& it : children) { if (it->getName() == _masterTechniqueName) { diff --git a/extensions/Particle3D/PU/CCPUSphereCollider.cpp b/extensions/Particle3D/PU/CCPUSphereCollider.cpp index d47272719e..dad1df1986 100644 --- a/extensions/Particle3D/PU/CCPUSphereCollider.cpp +++ b/extensions/Particle3D/PU/CCPUSphereCollider.cpp @@ -99,7 +99,7 @@ void PUSphereCollider::calculateDirectionAfterCollision(PUParticle3D* particle, void PUSphereCollider::updatePUAffector(PUParticle3D* particle, float /*deltaTime*/) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; _predictedPosition = particle->position + _velocityScale * particle->direction; diff --git a/extensions/Particle3D/PU/CCPUTextureAnimator.cpp b/extensions/Particle3D/PU/CCPUTextureAnimator.cpp index 70a9ef4adc..ff225e6f78 100644 --- a/extensions/Particle3D/PU/CCPUTextureAnimator.cpp +++ b/extensions/Particle3D/PU/CCPUTextureAnimator.cpp @@ -225,7 +225,7 @@ void PUTextureAnimator::updatePUAffector(PUParticle3D* particle, float deltaTime // if (particle->particleType != Particle::PT_VISUAL) // return; - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; // Determine the next texture coords index diff --git a/extensions/Particle3D/PU/CCPUTextureRotator.cpp b/extensions/Particle3D/PU/CCPUTextureRotator.cpp index 1d89267b1b..5898be17f8 100644 --- a/extensions/Particle3D/PU/CCPUTextureRotator.cpp +++ b/extensions/Particle3D/PU/CCPUTextureRotator.cpp @@ -128,7 +128,7 @@ void PUTextureRotator::initParticleForEmission(PUParticle3D* particle) void PUTextureRotator::updatePUAffector(PUParticle3D* particle, float deltaTime) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; //// Only continue if the particle is a visual particle diff --git a/extensions/Particle3D/PU/CCPUVelocityMatchingAffector.cpp b/extensions/Particle3D/PU/CCPUVelocityMatchingAffector.cpp index 23fb98c733..04421fb7a9 100644 --- a/extensions/Particle3D/PU/CCPUVelocityMatchingAffector.cpp +++ b/extensions/Particle3D/PU/CCPUVelocityMatchingAffector.cpp @@ -62,7 +62,7 @@ void PUVelocityMatchingAffector::setRadius(float radius) void PUVelocityMatchingAffector::updatePUAffector(PUParticle3D* /*particle*/, float /*deltaTime*/) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) //{ // PUParticle3D *particle = iter; // // Determine neighbouring particles. diff --git a/extensions/Particle3D/PU/CCPUVortexAffector.cpp b/extensions/Particle3D/PU/CCPUVortexAffector.cpp index b36fbd8bd1..10ea225aba 100644 --- a/extensions/Particle3D/PU/CCPUVortexAffector.cpp +++ b/extensions/Particle3D/PU/CCPUVortexAffector.cpp @@ -80,7 +80,7 @@ float PUVortexAffector::calculateRotationSpeed() void PUVortexAffector::updatePUAffector(PUParticle3D* particle, float /*deltaTime*/) { - // for (auto iter : _particleSystem->getParticles()) + // for (auto&& iter : _particleSystem->getParticles()) { // PUParticle3D *particle = iter; // Explicitly check on 'freezed', because it passes the techniques' validation. diff --git a/extensions/cocostudio/ActionTimeline/CCActionTimeline.cpp b/extensions/cocostudio/ActionTimeline/CCActionTimeline.cpp index a19b06da39..85f228a1f3 100644 --- a/extensions/cocostudio/ActionTimeline/CCActionTimeline.cpp +++ b/extensions/cocostudio/ActionTimeline/CCActionTimeline.cpp @@ -173,16 +173,16 @@ ActionTimeline* ActionTimeline::clone() const newAction->setDuration(_duration); newAction->setTimeSpeed(_timeSpeed); - for (auto timelines : _timelineMap) + for (auto&& timelines : _timelineMap) { - for (auto timeline : timelines.second) + for (auto&& timeline : timelines.second) { Timeline* newTimeline = timeline->clone(); newAction->addTimeline(newTimeline); } } - for (auto info : _animationInfos) + for (auto&& info : _animationInfos) { newAction->addAnimationInfo(info.second); } @@ -235,7 +235,7 @@ void foreachNodeDescendant(Node* parent, tCallBack callback) callback(parent); auto& children = parent->getChildren(); - for (auto child : children) + for (auto&& child : children) { foreachNodeDescendant(child, callback); } @@ -255,7 +255,7 @@ void ActionTimeline::startWithTarget(Node* target) if (_timelineMap.find(actionTag) != _timelineMap.end()) { auto timelines = this->_timelineMap[actionTag]; - for (auto timeline : timelines) + for (auto&& timeline : timelines) { timeline->setNode(child); } @@ -410,7 +410,7 @@ void ActionTimeline::emitFrameEndCallFuncs(int frameIndex) if (clipEndCallsIter != _frameEndCallFuncs.end()) { auto clipEndCalls = (*clipEndCallsIter).second; - for (auto call : clipEndCalls) + for (auto&& call : clipEndCalls) (call).second(); } } diff --git a/extensions/cocostudio/ActionTimeline/CCBoneNode.cpp b/extensions/cocostudio/ActionTimeline/CCBoneNode.cpp index 14fa864c41..76c86f06ca 100644 --- a/extensions/cocostudio/ActionTimeline/CCBoneNode.cpp +++ b/extensions/cocostudio/ActionTimeline/CCBoneNode.cpp @@ -119,7 +119,7 @@ void BoneNode::addSkin(SkinNode* skin, bool isDisplay, bool hideOthers) AXASSERT(skin != nullptr, "Argument must be non-nil"); if (hideOthers) { - for (auto& bonskin : _boneSkins) + for (auto&& bonskin : _boneSkins) { bonskin->setVisible(false); } @@ -152,7 +152,7 @@ void BoneNode::removeFromBoneList(BoneNode* bone) { auto subBones = bone->getAllSubBones(); subBones.pushBack(bone); - for (auto subBone : subBones) + for (auto&& subBone : subBones) { if (subBone->_rootSkeleton == nullptr) continue; @@ -186,7 +186,7 @@ void BoneNode::addToBoneList(BoneNode* bone) { auto subBones = bone->getAllSubBones(); subBones.pushBack(bone); - for (auto subBone : subBones) + for (auto&& subBone : subBones) { subBone->_rootSkeleton = _rootSkeleton; auto bonename = subBone->getName(); @@ -227,7 +227,7 @@ void BoneNode::removeFromSkinList(SkinNode* skin) void BoneNode::displaySkin(SkinNode* skin, bool hideOthers) { - for (auto boneskin : _boneSkins) + for (auto&& boneskin : _boneSkins) { if (boneskin == skin) { @@ -242,7 +242,7 @@ void BoneNode::displaySkin(SkinNode* skin, bool hideOthers) void BoneNode::displaySkin(std::string_view skinName, bool hideOthers) { - for (auto& skin : _boneSkins) + for (auto&& skin : _boneSkins) { if (skinName == skin->getName()) { @@ -320,7 +320,7 @@ void BoneNode::setBlendFunc(const axis::BlendFunc& blendFunc) if (_blendFunc != blendFunc) { _blendFunc = blendFunc; - for (auto& skin : _boneSkins) + for (auto&& skin : _boneSkins) { auto blendSkin = dynamic_cast(skin); if (nullptr != blendSkin) diff --git a/extensions/cocostudio/ActionTimeline/CCSkeletonNode.cpp b/extensions/cocostudio/ActionTimeline/CCSkeletonNode.cpp index 882ffd6ee4..120870e3e6 100644 --- a/extensions/cocostudio/ActionTimeline/CCSkeletonNode.cpp +++ b/extensions/cocostudio/ActionTimeline/CCSkeletonNode.cpp @@ -134,7 +134,7 @@ SkeletonNode::SkeletonNode() : BoneNode(), _subBonesDirty(true), _subBonesOrderD SkeletonNode::~SkeletonNode() { - for (auto& bonepair : _subBonesMap) + for (auto&& bonepair : _subBonesMap) { setRootSkeleton(bonepair.second, nullptr); } @@ -300,7 +300,7 @@ void SkeletonNode::batchDrawAllSubBones() void SkeletonNode::changeSkins(const hlookup::string_map& boneSkinNameMap) { - for (auto& boneskin : boneSkinNameMap) + for (auto&& boneskin : boneSkinNameMap) { auto bone = getBoneNode(boneskin.first); if (nullptr != bone) diff --git a/extensions/cocostudio/ActionTimeline/CCTimeLine.cpp b/extensions/cocostudio/ActionTimeline/CCTimeLine.cpp index 8fc5e586e8..af885a761a 100644 --- a/extensions/cocostudio/ActionTimeline/CCTimeLine.cpp +++ b/extensions/cocostudio/ActionTimeline/CCTimeLine.cpp @@ -72,7 +72,7 @@ Timeline* Timeline::clone() Timeline* timeline = Timeline::create(); timeline->_actionTag = _actionTag; - for (auto frame : _frames) + for (auto&& frame : _frames) { Frame* newFrame = frame->clone(); timeline->addFrame(newFrame); @@ -101,7 +101,7 @@ void Timeline::removeFrame(Frame* frame) void Timeline::setNode(Node* node) { - for (auto frame : _frames) + for (auto&& frame : _frames) { frame->setNode(node); } diff --git a/extensions/cocostudio/CCActionManagerEx.cpp b/extensions/cocostudio/CCActionManagerEx.cpp index ea59f0356f..ae9c1b0979 100644 --- a/extensions/cocostudio/CCActionManagerEx.cpp +++ b/extensions/cocostudio/CCActionManagerEx.cpp @@ -167,7 +167,7 @@ ActionObject* ActionManagerEx::stopActionByName(const char* jsonName, const char void ActionManagerEx::releaseActions() { - for (auto& iter : _actionDic) + for (auto&& iter : _actionDic) { axis::Vector objList = iter.second; ssize_t listCount = objList.size(); diff --git a/extensions/cocostudio/CCActionNode.cpp b/extensions/cocostudio/CCActionNode.cpp index 6d8e042def..459cb65e05 100644 --- a/extensions/cocostudio/CCActionNode.cpp +++ b/extensions/cocostudio/CCActionNode.cpp @@ -68,7 +68,7 @@ ActionNode::~ActionNode() AX_SAFE_RELEASE(_object); - for (auto object : _frameArray) + for (auto&& object : _frameArray) { object->clear(); AX_SAFE_DELETE(object); @@ -460,7 +460,7 @@ void ActionNode::deleteFrame(ActionFrame* frame) void ActionNode::clearAllFrame() { - for (auto array : _frameArray) + for (auto&& array : _frameArray) { array->clear(); } diff --git a/extensions/cocostudio/CCArmature.cpp b/extensions/cocostudio/CCArmature.cpp index a653a96422..0dbd20972e 100644 --- a/extensions/cocostudio/CCArmature.cpp +++ b/extensions/cocostudio/CCArmature.cpp @@ -134,7 +134,7 @@ bool Armature::init(std::string_view name) _armatureData = armatureData; - for (auto& element : armatureData->boneDataDic) + for (auto&& element : armatureData->boneDataDic) { Bone* bone = createBone(element.first); @@ -375,7 +375,7 @@ void Armature::draw(axis::Renderer* renderer, const Mat4& transform, uint32_t fl // AX_NODE_DRAW_SETUP(); } - for (auto& object : _children) + for (auto&& object : _children) { if (Bone* bone = dynamic_cast(object)) { @@ -533,7 +533,7 @@ void Armature::setParentBone(Bone* parentBone) { _parentBone = parentBone; - for (auto& element : _boneDic) + for (auto&& element : _boneDic) { element.second->setArmature(this); } @@ -548,7 +548,7 @@ Bone* Armature::getParentBone() const void Armature::setColliderFilter(ColliderFilter* filter) { - for (auto& element : _boneDic) + for (auto&& element : _boneDic) { element.second->setColliderFilter(filter); } @@ -557,7 +557,7 @@ void Armature::setColliderFilter(ColliderFilter* filter) void Armature::drawContour() { - for (auto& element : _boneDic) + for (auto&& element : _boneDic) { Bone* bone = element.second; ColliderDetector* detector = bone->getColliderDetector(); @@ -567,7 +567,7 @@ void Armature::drawContour() const axis::Vector& bodyList = detector->getColliderBodyList(); - for (auto& object : bodyList) + for (auto&& object : bodyList) { ColliderBody* body = static_cast(object); const std::vector& vertexList = body->getCalculatedVertexList(); @@ -618,13 +618,13 @@ void Armature::setBody(b2Body* body) _body = body; _body->SetUserData(this); - for (auto& object : _children) + for (auto&& object : _children) { if (Bone* bone = dynamic_cast(object)) { auto displayList = bone->getDisplayManager()->getDecorativeDisplayList(); - for (auto displayObject : displayList) + for (auto&& displayObject : displayList) { ColliderDetector* detector = static_cast(displayObject)->getColliderDetector(); if (detector != nullptr) diff --git a/extensions/cocostudio/CCArmatureAnimation.cpp b/extensions/cocostudio/CCArmatureAnimation.cpp index 03e03dc5b5..2d020a9867 100644 --- a/extensions/cocostudio/CCArmatureAnimation.cpp +++ b/extensions/cocostudio/CCArmatureAnimation.cpp @@ -139,7 +139,7 @@ void ArmatureAnimation::setSpeedScale(float speedScale) _processScale = !_movementData ? _speedScale : _speedScale * _movementData->scale; auto& map = _armature->getBoneDic(); - for (auto& element : map) + for (auto&& element : map) { Bone* bone = element.second; @@ -213,7 +213,7 @@ void ArmatureAnimation::play(std::string_view animationName, int durationTo, int _tweenList.clear(); auto& map = _armature->getBoneDic(); - for (auto& element : map) + for (auto&& element : map) { Bone* bone = element.second; movementBoneData = static_cast(_movementData->movBoneDataDic.at(bone->getName())); @@ -283,7 +283,7 @@ void ArmatureAnimation::playWithIndexes(const std::vector& movementIndexes, std::vector& movName = _animationData->movementNames; - for (auto& index : movementIndexes) + for (auto&& index : movementIndexes) { std::string name = movName.at(index); _movementList.push_back(name); diff --git a/extensions/cocostudio/CCBatchNode.cpp b/extensions/cocostudio/CCBatchNode.cpp index bb69ff6391..6a5d3f55db 100644 --- a/extensions/cocostudio/CCBatchNode.cpp +++ b/extensions/cocostudio/CCBatchNode.cpp @@ -134,7 +134,7 @@ void BatchNode::draw(Renderer* renderer, const Mat4& transform, uint32_t flags) // AX_NODE_DRAW_SETUP(); bool pushed = false; - for (auto object : _children) + for (auto&& object : _children) { Armature* armature = dynamic_cast(object); if (armature) diff --git a/extensions/cocostudio/CCBone.cpp b/extensions/cocostudio/CCBone.cpp index ecfda6e184..723e6ecdf5 100644 --- a/extensions/cocostudio/CCBone.cpp +++ b/extensions/cocostudio/CCBone.cpp @@ -312,7 +312,7 @@ void Bone::removeChildBone(Bone* bone, bool recursion) { auto ccbones = bone->_children; - for (auto& object : ccbones) + for (auto&& object : ccbones) { Bone* ccBone = static_cast(object); bone->removeChildBone(ccBone, recursion); @@ -448,7 +448,7 @@ void Bone::setColliderFilter(ColliderFilter* filter) { auto array = _displayManager->getDecorativeDisplayList(); - for (auto& object : array) + for (auto&& object : array) { DecorativeDisplay* decoDisplay = static_cast(object); if (ColliderDetector* detector = decoDisplay->getColliderDetector()) diff --git a/extensions/cocostudio/CCColliderDetector.cpp b/extensions/cocostudio/CCColliderDetector.cpp index 93399d3b06..72125602db 100644 --- a/extensions/cocostudio/CCColliderDetector.cpp +++ b/extensions/cocostudio/CCColliderDetector.cpp @@ -233,7 +233,7 @@ void ColliderDetector::setActive(bool active) } else { - for (auto& object : _colliderBodyList) + for (auto&& object : _colliderBodyList) { ColliderBody* colliderBody = (ColliderBody*)object; b2Fixture* fixture = colliderBody->getB2Fixture(); @@ -248,7 +248,7 @@ void ColliderDetector::setActive(bool active) { if (_active) { - for (auto& object : _colliderBodyList) + for (auto&& object : _colliderBodyList) { ColliderBody* colliderBody = (ColliderBody*)object; cpShape* shape = colliderBody->getShape(); @@ -260,7 +260,7 @@ void ColliderDetector::setActive(bool active) } else { - for (auto& object : _colliderBodyList) + for (auto&& object : _colliderBodyList) { ColliderBody* colliderBody = (ColliderBody*)object; cpShape* shape = colliderBody->getShape(); @@ -289,7 +289,7 @@ void ColliderDetector::setColliderFilter(ColliderFilter* filter) { *_filter = *filter; - for (auto& object : _colliderBodyList) + for (auto&& object : _colliderBodyList) { ColliderBody* colliderBody = (ColliderBody*)object; colliderBody->setColliderFilter(filter); @@ -322,7 +322,7 @@ void ColliderDetector::updateTransform(Mat4& t) return; } - for (auto& object : _colliderBodyList) + for (auto&& object : _colliderBodyList) { ColliderBody* colliderBody = (ColliderBody*)object; ContourData* contourData = colliderBody->getContourData(); @@ -395,7 +395,7 @@ void ColliderDetector::setBody(b2Body* pBody) { _body = pBody; - for (auto& object : _colliderBodyList) + for (auto&& object : _colliderBodyList) { ColliderBody* colliderBody = (ColliderBody*)object; @@ -404,7 +404,7 @@ void ColliderDetector::setBody(b2Body* pBody) b2Vec2* b2bv = new b2Vec2[contourData->vertexList.size()]; int i = 0; - for (auto& v : contourData->vertexList) + for (auto&& v : contourData->vertexList) { b2bv[i].Set(v.x / PT_RATIO, v.y / PT_RATIO); i++; @@ -442,7 +442,7 @@ void ColliderDetector::setBody(cpBody* pBody) { _body = pBody; - for (auto& object : _colliderBodyList) + for (auto&& object : _colliderBodyList) { ColliderBody* colliderBody = (ColliderBody*)object; diff --git a/extensions/cocostudio/CCDisplayManager.cpp b/extensions/cocostudio/CCDisplayManager.cpp index dd9da15108..286af53c54 100644 --- a/extensions/cocostudio/CCDisplayManager.cpp +++ b/extensions/cocostudio/CCDisplayManager.cpp @@ -339,7 +339,7 @@ void DisplayManager::initDisplayList(BoneData* boneData) CS_RETURN_IF(!boneData); - for (auto& object : boneData->displayDataList) + for (auto&& object : boneData->displayDataList) { DisplayData* displayData = static_cast(object); diff --git a/extensions/cocostudio/SpineSkeletonDataCache.cpp b/extensions/cocostudio/SpineSkeletonDataCache.cpp index 7285a8e49f..485aa2179a 100644 --- a/extensions/cocostudio/SpineSkeletonDataCache.cpp +++ b/extensions/cocostudio/SpineSkeletonDataCache.cpp @@ -109,7 +109,7 @@ SpineSkeletonDataCache::SkeletonData* SpineSkeletonDataCache::addData(const char void SpineSkeletonDataCache::removeAllData(void) { - for (auto& e : _cacheTable) + for (auto&& e : _cacheTable) { e.second->release(); } @@ -260,7 +260,7 @@ SpineSkeletonDataCache::SkeletonData* SpineSkeletonDataCache::addData(const char void SpineSkeletonDataCache::removeAllData(void) { - for (auto& e : _cacheTable) + for (auto&& e : _cacheTable) { e.second->release(); } diff --git a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp index ff9b06705f..ce079ceaaa 100644 --- a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp +++ b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp @@ -1401,7 +1401,7 @@ void ActionStacked::runActionsInSprite(Sprite* sprite) void ActionStacked::onTouchesEnded(const std::vector& touches, Event* event) { - for (auto& touch : touches) + for (auto&& touch : touches) { auto location = touch->getLocation(); addNewSpriteWithCoords(location); diff --git a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp index 73a847cf7c..207465b236 100644 --- a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp +++ b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp @@ -201,7 +201,7 @@ BillBoardTest::BillBoardTest() : _camera(nullptr) void BillBoardTest::menuCallback_orientedPoint(Ref* sender) { - for (auto& billboard : _billboards) + for (auto&& billboard : _billboards) { billboard->setMode(BillBoard::Mode::VIEW_POINT_ORIENTED); } @@ -209,7 +209,7 @@ void BillBoardTest::menuCallback_orientedPoint(Ref* sender) void BillBoardTest::menuCallback_orientedPlane(Ref* sender) { - for (auto& billboard : _billboards) + for (auto&& billboard : _billboards) { billboard->setMode(BillBoard::Mode::VIEW_PLANE_ORIENTED); } diff --git a/tests/cpp-tests/Classes/FileUtilsTest/FileUtilsTest.cpp b/tests/cpp-tests/Classes/FileUtilsTest/FileUtilsTest.cpp index a306552eeb..e7506d10d7 100644 --- a/tests/cpp-tests/Classes/FileUtilsTest/FileUtilsTest.cpp +++ b/tests/cpp-tests/Classes/FileUtilsTest/FileUtilsTest.cpp @@ -556,7 +556,7 @@ void TestGetContents::onEnter() return std::string("failed: read as zero terminated string"); std::string files[] = {_generatedFile, "background.wav", "fileLookup.plist"}; - for (auto& file : files) + for (auto&& file : files) { std::string sbuf; diff --git a/tests/cpp-tests/Classes/FontTest/FontTest.cpp b/tests/cpp-tests/Classes/FontTest/FontTest.cpp index 1510355afb..9679a55717 100644 --- a/tests/cpp-tests/Classes/FontTest/FontTest.cpp +++ b/tests/cpp-tests/Classes/FontTest/FontTest.cpp @@ -56,7 +56,7 @@ static TextVAlignment verticalAlignment[] = { FontTests::FontTests() { - for (auto& fontFile : fontList) + for (auto&& fontFile : fontList) { addTestCase("FontTests", [&]() { vAlignIdx = 0; @@ -64,7 +64,7 @@ FontTests::FontTests() }); } - for (auto& fontFile : fontList) + for (auto&& fontFile : fontList) { addTestCase("FontTests", [&]() { vAlignIdx = 1; @@ -72,7 +72,7 @@ FontTests::FontTests() }); } - for (auto& fontFile : fontList) + for (auto&& fontFile : fontList) { addTestCase("FontTests", [&]() { vAlignIdx = 2; diff --git a/tests/cpp-tests/Classes/LayerTest/LayerTest.cpp b/tests/cpp-tests/Classes/LayerTest/LayerTest.cpp index 0c00ccde1b..7efc5e63c7 100644 --- a/tests/cpp-tests/Classes/LayerTest/LayerTest.cpp +++ b/tests/cpp-tests/Classes/LayerTest/LayerTest.cpp @@ -874,7 +874,7 @@ void LayerRadialGradientTest::listviewCallback(axis::Ref* sender, axis::ui::List { // clear all text to white auto listview = static_cast(sender); - for (auto& item : listview->getItems()) + for (auto&& item : listview->getItems()) static_cast(item)->setColor(axis::Color3B::WHITE); _currentSeletedItemIndex = (int)listview->getCurSelectedIndex(); diff --git a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp index f892fe1f4c..903979dc56 100644 --- a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp +++ b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp @@ -165,7 +165,7 @@ void Material_2DEffects::updateCCTimeUniforms(float) { float time = Director::getInstance()->getTotalFrames() * Director::getInstance()->getAnimationInterval(); Vec4 random(time / 10.0f, time, time * 2.0f, time * 4.0f); - for (auto& loc : timeUniforms) + for (auto&& loc : timeUniforms) { loc.programState->setUniform(loc.location, &random, sizeof(random)); } diff --git a/tests/cpp-tests/Classes/MeshRendererTest/MeshRendererTest.cpp b/tests/cpp-tests/Classes/MeshRendererTest/MeshRendererTest.cpp index 9e78bfad12..abed285b3e 100644 --- a/tests/cpp-tests/Classes/MeshRendererTest/MeshRendererTest.cpp +++ b/tests/cpp-tests/Classes/MeshRendererTest/MeshRendererTest.cpp @@ -208,7 +208,7 @@ void MeshRendererBasicTest::addNewMeshWithCoords(Vec2 p) void MeshRendererBasicTest::onTouchesEnded(const std::vector& touches, Event* event) { - for (auto touch : touches) + for (auto&&touch : touches) { auto location = touch->getLocation(); @@ -504,7 +504,7 @@ void MeshRendererFakeShadowTest::onTouchesMoved(const std::vector& touch void MeshRendererFakeShadowTest::onTouchesEnded(const std::vector& touches, axis::Event* event) { - for (auto& item : touches) + for (auto&&item : touches) { auto touch = item; auto location = touch->getLocationInView(); @@ -743,7 +743,7 @@ MeshRendererEffectTest::MeshRendererEffectTest() _backToForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom*) { auto material = MeshMaterial::createWithFilename("MeshRendererTest/outline.material"); material->setTechnique("outline_noneskinned"); - for (auto& mesh : _meshes) + for (auto&&mesh : _meshes) { mesh->setMaterial(material->clone()); } @@ -805,7 +805,7 @@ void MeshRendererEffectTest::addNewMeshWithCoords(Vec2 p) void MeshRendererEffectTest::onTouchesEnded(const std::vector& touches, Event* event) { - for (auto touch : touches) + for (auto&&touch : touches) { auto location = touch->getLocation(); @@ -966,7 +966,7 @@ void MeshRendererWithSkinTest::switchAnimationQualityCallback(Ref* sender) _menuItem->setString(getAnimationQualityMessage()); - for (auto iter : _meshes) + for (auto&&iter : _meshes) { RepeatForever* repAction = dynamic_cast(iter->getActionByTag(110)); Animate3D* animate3D = dynamic_cast(repAction->getInnerAction()); @@ -976,7 +976,7 @@ void MeshRendererWithSkinTest::switchAnimationQualityCallback(Ref* sender) void MeshRendererWithSkinTest::onTouchesEnded(const std::vector& touches, Event* event) { - for (auto touch : touches) + for (auto&&touch : touches) { auto location = touch->getLocation(); @@ -997,7 +997,7 @@ MeshRendererWithSkinOutlineTest::MeshRendererWithSkinOutlineTest() _backToForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom*) { auto material = MeshMaterial::createWithFilename("MeshRendererTest/outline.material"); material->setTechnique("outline_skinned"); - for (auto& mesh : _meshes) + for (auto&&mesh : _meshes) { mesh->setMaterial(material->clone()); } @@ -1059,7 +1059,7 @@ void MeshRendererWithSkinOutlineTest::addNewMeshWithCoords(Vec2 p) void MeshRendererWithSkinOutlineTest::onTouchesEnded(const std::vector& touches, Event* event) { - for (auto touch : touches) + for (auto&&touch : touches) { auto location = touch->getLocation(); @@ -1174,7 +1174,7 @@ void Animate3DTest::renewCallBack() void Animate3DTest::onTouchesEnded(const std::vector& touches, Event* event) { - for (auto touch : touches) + for (auto&&touch : touches) { auto location = touch->getLocation(); diff --git a/tests/cpp-tests/Classes/NavMeshTest/NavMeshTest.cpp b/tests/cpp-tests/Classes/NavMeshTest/NavMeshTest.cpp index 26976152f6..9bd1821ecf 100644 --- a/tests/cpp-tests/Classes/NavMeshTest/NavMeshTest.cpp +++ b/tests/cpp-tests/Classes/NavMeshTest/NavMeshTest.cpp @@ -68,7 +68,7 @@ NavMeshBaseTestDemo::NavMeshBaseTestDemo() : _camera(nullptr), _needMoveAgents(f NavMeshBaseTestDemo::~NavMeshBaseTestDemo() { - for (auto iter : _agents) + for (auto&& iter : _agents) { AgentUserData* data = static_cast(iter.first->getUserData()); delete data; @@ -222,7 +222,7 @@ Vec3 jump(const Vec3* pV1, const Vec3* pV2, float height, float t) void NavMeshBaseTestDemo::moveAgents(const axis::Vec3& des) { - for (auto iter : _agents) + for (auto&& iter : _agents) { NavMeshAgent::MoveCallback callback = [](NavMeshAgent* agent, float totalTimeAfterMove) { AgentUserData* data = static_cast(agent->getUserData()); @@ -258,7 +258,7 @@ void NavMeshBaseTestDemo::moveAgents(const axis::Vec3& des) void NavMeshBaseTestDemo::update(float delta) { - for (auto iter : _agents) + for (auto&& iter : _agents) { float speed = iter.first->getCurrentVelocity().length() * 0.2f; iter.second->setSpeed(0.0f < speed ? speed : 0.0f); diff --git a/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.cpp b/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.cpp index b04c6af65e..2fb9c55fbd 100644 --- a/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.cpp +++ b/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.cpp @@ -116,7 +116,7 @@ void Particle3DTestDemo::update(float delta) { unsigned int count = 0; auto children = ps->getChildren(); - for (auto iter : children) + for (auto&& iter : children) { ParticleSystem3D* child = dynamic_cast(iter); if (child) diff --git a/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp index 5e796d2947..cc4dc86c4a 100644 --- a/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp +++ b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp @@ -701,7 +701,7 @@ bool Physics3DCollisionCallbackDemo::init() float scale = 2.0f; std::vector trianglesList = Bundle3D::getTrianglesList("MeshRendererTest/boss.c3b"); - for (auto& it : trianglesList) + for (auto&& it : trianglesList) { it *= scale; } @@ -736,7 +736,7 @@ bool Physics3DCollisionCallbackDemo::init() } // AXLOG("------------BoxB Collision Info------------"); // AXLOG("Collision Point Num: %d", ci.collisionPointList.size()); - // for (auto &iter : ci.collisionPointList){ + // for (auto&& iter : ci.collisionPointList){ // AXLOG("Collision Position On A: (%.2f, %.2f, %.2f)", iter.worldPositionOnA.x, iter.worldPositionOnA.y, // iter.worldPositionOnA.z); AXLOG("Collision Position On B: (%.2f, %.2f, %.2f)", // iter.worldPositionOnB.x, iter.worldPositionOnB.y, iter.worldPositionOnB.z); AXLOG("Collision Normal diff --git a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp index c56acb7ae6..023231ec64 100644 --- a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp +++ b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp @@ -396,7 +396,7 @@ void PhysicsDemoClickAdd::onTouchesEnded(const std::vector& touches, Eve { // Add a new body/atlas sprite at the touched location - for (auto touch : touches) + for (auto& touch : touches) { auto location = touch->getLocation(); diff --git a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp index cb837c517b..7f8ac0a37a 100644 --- a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp +++ b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp @@ -596,7 +596,7 @@ void SchedulerUpdate::removeUpdates(float /*dt*/) { auto& children = getChildren(); - for (auto& c : children) + for (auto&& c : children) { auto obj = static_cast(c); auto node = static_cast(obj); @@ -1374,7 +1374,7 @@ void SchedulerRemoveEntryWhileUpdate::onEnter() void SchedulerRemoveEntryWhileUpdate::onExit() { - for (auto obj : _testvector) + for (auto&& obj : _testvector) { getScheduler()->unscheduleUpdate(obj); delete obj; diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index b4239200c1..d7efe44a2e 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -126,7 +126,7 @@ public: { // negative effects: order < 0 int idx = 0; - for (auto& effect : _effects) + for (auto&&effect : _effects) { if (std::get<0>(effect) >= 0) @@ -149,7 +149,7 @@ public: renderer->addCommand(&_trianglesCommand); // positive effects: order >= 0 - for (auto it = std::begin(_effects) + idx; it != std::end(_effects); ++it) + for (auto&& it = std::begin(_effects) + idx; it != std::end(_effects); ++it) { QuadCommand& q = std::get<2>(*it); auto* programState = std::get<1>(*it)->getProgramState(); @@ -166,7 +166,7 @@ protected: EffectSprite() : _defaultEffect(nullptr) { _effects.reserve(2); } ~EffectSprite() { - for (auto& tuple : _effects) + for (auto&&tuple : _effects) { std::get<1>(tuple)->release(); } @@ -577,7 +577,7 @@ bool EffectSpriteLamp::init() void EffectSpriteLamp::onTouchesBegan(const std::vector& touches, Event* unused_event) { - for (auto& item : touches) + for (auto&&item : touches) { auto touch = item; auto s = Director::getInstance()->getWinSize(); @@ -593,7 +593,7 @@ void EffectSpriteLamp::onTouchesBegan(const std::vector& touches, Event* void EffectSpriteLamp::onTouchesMoved(const std::vector& touches, Event* unused_event) { - for (auto& item : touches) + for (auto&&item : touches) { auto touch = item; auto s = Director::getInstance()->getWinSize(); @@ -609,7 +609,7 @@ void EffectSpriteLamp::onTouchesMoved(const std::vector& touches, Event* void EffectSpriteLamp::onTouchesEnded(const std::vector& touches, Event* unused_event) { - for (auto& item : touches) + for (auto&&item : touches) { auto touch = item; auto s = Director::getInstance()->getWinSize(); diff --git a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp index 42713807ce..f20f3f7870 100644 --- a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp +++ b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp @@ -327,7 +327,7 @@ void SpritePolygonTestSlider::changeEpsilon(axis::Ref* pSender, axis::ui::Slider { axis::ui::Slider* slider = dynamic_cast(pSender); float epsilon = powf(slider->getPercent() / 100.0, 2) * 19.0f + 1.0f; - for (auto child : _children) + for (auto&&child : _children) { if (child->getName().size()) { diff --git a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp index 75e0689d80..77f557c576 100644 --- a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp +++ b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp @@ -187,7 +187,7 @@ void Sprite1::addNewSpriteWithCoords(Vec2 p) void Sprite1::onTouchesEnded(const std::vector& touches, Event* event) { - for (auto touch : touches) + for (auto& touch : touches) { auto location = touch->getLocation(); @@ -259,7 +259,7 @@ void SpriteBatchNode1::addNewSpriteWithCoords(Vec2 p) void SpriteBatchNode1::onTouchesEnded(const std::vector& touches, Event* event) { - for (auto& touch : touches) + for (auto&& touch : touches) { auto location = touch->getLocation(); diff --git a/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp b/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp index fd11278b19..f2be3f94a6 100644 --- a/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp +++ b/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp @@ -242,7 +242,7 @@ void TextureETC1Alpha::addNewSpriteWithCoords(Vec2 p) void TextureETC1Alpha::onTouchesEnded(const std::vector& touches, Event* event) { - for (auto touch : touches) + for (auto&& touch : touches) { auto location = touch->getLocation(); @@ -305,7 +305,7 @@ void TextureETC2::addNewSpriteWithCoords() void TextureETC2::onTouchesEnded(const std::vector& touches, Event* event) { - // for (auto touch : touches) + // for (auto&& touch : touches) //{ // auto location = touch->getLocation(); @@ -371,7 +371,7 @@ void TextureBMP::addNewSpriteWithCoords(Vec2 p) void TextureBMP::onTouchesEnded(const std::vector& touches, Event* event) { - for (auto touch : touches) + for (auto&& touch : touches) { auto location = touch->getLocation(); diff --git a/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp b/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp index e2a289dda2..1c008f367f 100644 --- a/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp +++ b/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp @@ -659,7 +659,7 @@ TMXOrthoObjectsTestNew::TMXOrthoObjectsTestNew() auto drawNode = DrawNode::create(); Color4F color(1.0, 1.0, 1.0, 1.0); - for (auto& obj : objects) + for (auto&& obj : objects) { ValueMap& dict = obj.asValueMap(); @@ -709,7 +709,7 @@ TMXIsoObjectsTestNew::TMXIsoObjectsTestNew() auto drawNode = DrawNode::create(); Color4F color(1.0, 1.0, 1.0, 1.0); - for (auto& obj : objects) + for (auto&& obj : objects) { ValueMap& dict = obj.asValueMap(); @@ -1340,7 +1340,7 @@ TMXGIDObjectsTestNew::TMXGIDObjectsTestNew() Color4F color(1.0, 1.0, 1.0, 1.0); auto group = map->getObjectGroup("Object Layer 1"); auto objects = group->getObjects(); - for (auto& obj : objects) + for (auto&& obj : objects) { ValueMap& dict = obj.asValueMap(); diff --git a/tests/cpp-tests/Classes/TouchesTest/TouchesTest.cpp b/tests/cpp-tests/Classes/TouchesTest/TouchesTest.cpp index c43ed65ac7..b9d6bf4a8a 100644 --- a/tests/cpp-tests/Classes/TouchesTest/TouchesTest.cpp +++ b/tests/cpp-tests/Classes/TouchesTest/TouchesTest.cpp @@ -105,7 +105,7 @@ PongLayer::PongLayer() _paddles = paddlesM; - for (auto& paddle : _paddles) + for (auto&& paddle : _paddles) { addChild(paddle); } @@ -128,7 +128,7 @@ void PongLayer::doStep(float delta) { _ball->move(delta); - for (auto& paddle : _paddles) + for (auto&& paddle : _paddles) { _ball->collideWithPaddle(paddle); } @@ -176,7 +176,7 @@ void ForceTouchTest::onTouchesBegan(const std::vector& touches, ax void ForceTouchTest::onTouchesMoved(const std::vector& touches, axis::Event* event) { - for (auto& t : touches) + for (auto&& t : touches) { float currentForce = t->getCurrentForce(); float maxForce = t->getMaxForce(); diff --git a/tests/cpp-tests/Classes/TransitionsTest/TransitionsTest.cpp b/tests/cpp-tests/Classes/TransitionsTest/TransitionsTest.cpp index 9904eef0a7..cf5a6ec3ad 100644 --- a/tests/cpp-tests/Classes/TransitionsTest/TransitionsTest.cpp +++ b/tests/cpp-tests/Classes/TransitionsTest/TransitionsTest.cpp @@ -225,7 +225,7 @@ TransitionsTests::TransitionsTests() { int sceneIndex = 0; - for (auto& test : transitions) + for (auto&& test : transitions) { addTestCase(test.name, [sceneIndex]() { auto scene = TransitionsTest::create(); diff --git a/tests/cpp-tests/Classes/UnitTest/UnitTest.cpp b/tests/cpp-tests/Classes/UnitTest/UnitTest.cpp index b568c3efbc..ba6f351cec 100644 --- a/tests/cpp-tests/Classes/UnitTest/UnitTest.cpp +++ b/tests/cpp-tests/Classes/UnitTest/UnitTest.cpp @@ -154,7 +154,7 @@ void TemplateVectorTest::onEnter() } int j = 1000; - for (auto& child : ret) + for (auto&& child : ret) { child->setTag(j++); } @@ -253,7 +253,7 @@ void TemplateVectorTest::onEnter() array2.pushBack(objB); array2.pushBack(objC); - for (auto obj : array1) + for (auto&& obj : array1) { array2.eraseObject(obj); } @@ -1132,7 +1132,7 @@ void ParseUriTest::onEnter() Uri u = Uri::parse(s); auto paramsList = u.getQueryParams(); std::map params; - for (auto& param : paramsList) + for (auto&¶m : paramsList) { params[param.first] = param.second; } @@ -1158,7 +1158,7 @@ void ParseUriTest::onEnter() Uri u = Uri::parse(s); auto paramsList = u.getQueryParams(); std::map params; - for (auto& param : paramsList) + for (auto&¶m : paramsList) { params[param.first] = param.second; } @@ -1174,7 +1174,7 @@ void ParseUriTest::onEnter() Uri u = Uri::parse(s); auto paramsList = u.getQueryParams(); std::map params; - for (auto& param : paramsList) + for (auto&¶m : paramsList) { params[param.first] = param.second; } @@ -1189,7 +1189,7 @@ void ParseUriTest::onEnter() Uri u = Uri::parse(s); auto paramsList = u.getQueryParams(); std::map params; - for (auto& param : paramsList) + for (auto&& param : paramsList) { params[param.first] = param.second; } diff --git a/tests/cpp-tests/Classes/controller.cpp b/tests/cpp-tests/Classes/controller.cpp index 3ffabe05a8..589732204d 100644 --- a/tests/cpp-tests/Classes/controller.cpp +++ b/tests/cpp-tests/Classes/controller.cpp @@ -203,7 +203,7 @@ void TestController::traverseTestList(TestList* testList) auto scheduler = _director->getScheduler(); int testIndex = 0; - for (auto& callback : testList->_testCallbacks) + for (auto&&callback : testList->_testCallbacks) { if (_stopAutoTest) break; @@ -260,7 +260,7 @@ void TestController::traverseTestSuite(TestSuite* testSuite) testSuite->_currTestIndex = -1; auto logIndentation = _logIndentation; - for (auto& callback : testSuite->_testCallbacks) + for (auto&&callback : testSuite->_testCallbacks) { auto testName = testSuite->_childTestNames[testIndex++]; @@ -534,7 +534,7 @@ static void signalHandler(int sig) static void initCrashCatch() { - for (auto sig : s_fatal_signals) + for (auto&&sig : s_fatal_signals) { signal(sig, signalHandler); } @@ -542,7 +542,7 @@ static void initCrashCatch() static void disableCrashCatch() { - for (auto sig : s_fatal_signals) + for (auto&&sig : s_fatal_signals) { signal(sig, SIG_DFL); } diff --git a/tests/fairygui-tests/Classes/EmojiParser.cpp b/tests/fairygui-tests/Classes/EmojiParser.cpp index 6be9016c26..3d467db606 100644 --- a/tests/fairygui-tests/Classes/EmojiParser.cpp +++ b/tests/fairygui-tests/Classes/EmojiParser.cpp @@ -6,7 +6,7 @@ EmojiParser::EmojiParser() { std::vector tags({ "88","am","bs","bz","ch","cool","dhq","dn","fd","gz","han","hx","hxiao","hxiu" }); - for (auto &str : tags) + for (auto&& str : tags) _handlers[":" + str] = UBB_TAG_HANDLER(EmojiParser::onTag_Emoji, this); }