Skip to content

Commit 28dd328

Browse files
authored
replace push_back() vs emplace_back() on extension (#785)
1 parent 45d4d49 commit 28dd328

File tree

56 files changed

+184
-184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+184
-184
lines changed

extensions/GUI/CCControlExtension/CCControl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void Control::removeTargetWithActionForControlEvent(Ref* target, Handler action,
210210
// Remove the corresponding invocation object
211211
if (shouldBeRemoved)
212212
{
213-
tobeRemovedInvocations.push_back(invocation);
213+
tobeRemovedInvocations.emplace_back(invocation);
214214
}
215215
}
216216

extensions/GUI/CCScrollView/CCScrollView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ bool ScrollView::onTouchBegan(Touch* touch, Event* /*event*/)
713713

714714
if (std::find(_touches.begin(), _touches.end(), touch) == _touches.end())
715715
{
716-
_touches.push_back(touch);
716+
_touches.emplace_back(touch);
717717
}
718718

719719
if (_touches.size() == 1)

extensions/Live2D/Framework/src/CubismFramework.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ void* CubismFramework::Allocate(csmSizeType size, const csmChar* fileName, csmIn
228228

229229
if (s_allocationList)
230230
{
231-
s_allocationList->push_back(address);
231+
s_allocationList->emplace_back(address);
232232
}
233233

234234
return address;
@@ -242,7 +242,7 @@ void* CubismFramework::AllocateAligned(csmSizeType size, csmUint32 alignment, co
242242

243243
if (s_allocationList)
244244
{
245-
s_allocationList->push_back(address);
245+
s_allocationList->emplace_back(address);
246246
}
247247

248248
return address;

extensions/Particle3D/CCParticle3DRender.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ void Particle3DModelRender::render(Renderer* renderer, const Mat4& transform, Pa
314314
}
315315
mesh->setTexture(_texFile);
316316
mesh->retain();
317-
_meshList.push_back(mesh);
317+
_meshList.emplace_back(mesh);
318318
}
319319
if (!_meshList.empty())
320320
{

extensions/Particle3D/CCParticleSystem3D.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void ParticleSystem3D::addAffector(Particle3DAffector* affector)
120120
{
121121
affector->_particleSystem = this;
122122
affector->retain();
123-
_affectors.push_back(affector);
123+
_affectors.emplace_back(affector);
124124
}
125125
}
126126

extensions/Particle3D/CCParticleSystem3D.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ class AX_EX_DLL DataPool
7575
if (_locked.empty())
7676
return nullptr;
7777
T* p = _locked.front();
78-
//_released.push_back(p);
78+
//_released.emplace_back(p);
7979
//_locked.erase(_locked.begin());
8080
_released.splice(_released.end(), _locked, _locked.begin());
8181
return p;
8282
}
8383

8484
void lockLatestData()
8585
{
86-
_locked.push_back(*_releasedIter);
86+
_locked.emplace_back(*_releasedIter);
8787
_releasedIter = _released.erase(_releasedIter);
8888
if (_releasedIter != _released.begin() && _releasedIter != _released.end())
8989
{
@@ -135,7 +135,7 @@ class AX_EX_DLL DataPool
135135
const PoolList& getActiveDataList() const { return _released; };
136136
const PoolList& getUnActiveDataList() const { return _locked; };
137137

138-
void addData(T* data) { _locked.push_back(data); }
138+
void addData(T* data) { _locked.emplace_back(data); }
139139

140140
bool empty() const { return _released.empty(); };
141141

extensions/Particle3D/PU/CCPUAffector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void PUAffector::addEmitterToExclude(std::string_view emitterName)
166166
auto iter = std::find(_excludedEmitters.begin(), _excludedEmitters.end(), emitterName);
167167
if (iter == _excludedEmitters.end())
168168
{
169-
_excludedEmitters.push_back(std::string{emitterName});
169+
_excludedEmitters.emplace_back(std::string{emitterName});
170170
}
171171
}
172172

extensions/Particle3D/PU/CCPUBeamRender.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void PUBeamRender::particleExpired(PUParticleSystem3D* /*particleSystem*/, PUPar
149149
PUParticle3DBeamVisualData* beamRendererVisualData =
150150
static_cast<PUParticle3DBeamVisualData*>(particle->visualData);
151151
beamRendererVisualData->setVisible(false, 0); // PU 1.4
152-
_visualData.push_back(beamRendererVisualData);
152+
_visualData.emplace_back(beamRendererVisualData);
153153
particle->visualData = nullptr;
154154
}
155155
}
@@ -279,8 +279,8 @@ void PUBeamRender::prepare()
279279
visualData->half[numDev].setZero();
280280
visualData->destinationHalf[numDev].setZero();
281281
}
282-
_allVisualData.push_back(visualData); // Managed by this renderer
283-
_visualData.push_back(visualData); // Used to assign to a particle
282+
_allVisualData.emplace_back(visualData); // Managed by this renderer
283+
_visualData.emplace_back(visualData); // Used to assign to a particle
284284
}
285285
}
286286

extensions/Particle3D/PU/CCPUDynamicAttribute.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ PUDynamicAttributeCurved::PUDynamicAttributeCurved(const PUDynamicAttributeCurve
169169
// Copy controlpoints
170170
for (const auto& controlPoint : dynamicAttributeCurved._controlPoints)
171171
{
172-
_controlPoints.push_back(controlPoint);
172+
_controlPoints.emplace_back(controlPoint);
173173
}
174174
processControlPoints();
175175
}
@@ -232,7 +232,7 @@ float PUDynamicAttributeCurved::getValue(float x)
232232
//-----------------------------------------------------------------------
233233
void PUDynamicAttributeCurved::addControlPoint(float x, float y)
234234
{
235-
_controlPoints.push_back(Vec2(x, y));
235+
_controlPoints.emplace_back(Vec2(x, y));
236236
}
237237
//-----------------------------------------------------------------------
238238
const PUDynamicAttributeCurved::ControlPointList& PUDynamicAttributeCurved::getControlPoints() const
@@ -314,7 +314,7 @@ void PUDynamicAttributeCurved::copyAttributesTo(PUDynamicAttribute* dynamicAttri
314314
for (it = _controlPoints.begin(); it != itEnd; ++it)
315315
{
316316
Vec2 controlPoint = *it;
317-
dynAttr->_controlPoints.push_back(controlPoint);
317+
dynAttr->_controlPoints.emplace_back(controlPoint);
318318
}
319319
dynAttr->processControlPoints();
320320
}

extensions/Particle3D/PU/CCPUMaterialManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void PUMaterialCache::addMaterial(PUMaterial* material)
113113
}
114114

115115
material->retain();
116-
_materialMap.push_back(material);
116+
_materialMap.emplace_back(material);
117117
}
118118

119119
#if (AX_TARGET_PLATFORM == AX_PLATFORM_IOS || AX_TARGET_PLATFORM == AX_PLATFORM_MAC)

0 commit comments

Comments
 (0)