Skip to content

Commit 787ee97

Browse files
committed
[clang-tidy] modernize-use-emplace
1 parent e51efc9 commit 787ee97

File tree

58 files changed

+223
-219
lines changed

Some content is hidden

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

58 files changed

+223
-219
lines changed

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Checks: "\
22
modernize-make-shared,\
33
modernize-make-unique,\
44
modernize-use-default-member-init,\
5+
modernize-use-emplace,\
56
performance-faster-string-find,\
67
performance-for-range-copy,\
78
performance-implicit-conversion-in-loop,\

xbmc/GUIInfoManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9908,7 +9908,7 @@ void CGUIInfoManager::SplitInfoString(const std::string &infoString, std::vector
99089908
if (!property.empty()) // add our property and parameters
99099909
{
99109910
StringUtils::ToLower(property);
9911-
info.emplace_back(Property(property, param));
9911+
info.emplace_back(property, param);
99129912
}
99139913
property.clear();
99149914
param.clear();
@@ -9926,7 +9926,7 @@ void CGUIInfoManager::SplitInfoString(const std::string &infoString, std::vector
99269926
if (!property.empty())
99279927
{
99289928
StringUtils::ToLower(property);
9929-
info.emplace_back(Property(property, param));
9929+
info.emplace_back(property, param);
99309930
}
99319931
}
99329932

xbmc/addons/addoninfo/AddonExtensions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ const EXT_ELEMENTS CAddonExtensions::GetElements(const std::string& id) const
5555
for (const auto& child : m_children)
5656
{
5757
if (child.first == id)
58-
children.push_back(std::make_pair(child.first, child.second));
58+
children.emplace_back(child.first, child.second);
5959
}
6060
return children;
6161
}
6262

6363
void CAddonExtensions::Insert(const std::string& id, const std::string& value)
6464
{
6565
EXT_VALUE extension;
66-
extension.push_back(std::make_pair(id, SExtValue(value)));
67-
m_values.push_back(std::make_pair(id, extension));
66+
extension.emplace_back(id, SExtValue(value));
67+
m_values.emplace_back(id, extension);
6868
}

xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Game.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,21 @@ class GameControllerLayout
5252
{
5353
provides_input = layout.provides_input;
5454
for (unsigned int i = 0; i < layout.digital_button_count; ++i)
55-
digital_buttons.push_back(layout.digital_buttons[i]);
55+
digital_buttons.emplace_back(layout.digital_buttons[i]);
5656
for (unsigned int i = 0; i < layout.analog_button_count; ++i)
57-
analog_buttons.push_back(layout.analog_buttons[i]);
57+
analog_buttons.emplace_back(layout.analog_buttons[i]);
5858
for (unsigned int i = 0; i < layout.analog_stick_count; ++i)
59-
analog_sticks.push_back(layout.analog_sticks[i]);
59+
analog_sticks.emplace_back(layout.analog_sticks[i]);
6060
for (unsigned int i = 0; i < layout.accelerometer_count; ++i)
61-
accelerometers.push_back(layout.accelerometers[i]);
61+
accelerometers.emplace_back(layout.accelerometers[i]);
6262
for (unsigned int i = 0; i < layout.key_count; ++i)
63-
keys.push_back(layout.keys[i]);
63+
keys.emplace_back(layout.keys[i]);
6464
for (unsigned int i = 0; i < layout.rel_pointer_count; ++i)
65-
rel_pointers.push_back(layout.rel_pointers[i]);
65+
rel_pointers.emplace_back(layout.rel_pointers[i]);
6666
for (unsigned int i = 0; i < layout.abs_pointer_count; ++i)
67-
abs_pointers.push_back(layout.abs_pointers[i]);
67+
abs_pointers.emplace_back(layout.abs_pointers[i]);
6868
for (unsigned int i = 0; i < layout.motor_count; ++i)
69-
motors.push_back(layout.motors[i]);
69+
motors.emplace_back(layout.motors[i]);
7070
}
7171
/*! @endcond */
7272

@@ -201,7 +201,7 @@ class ATTR_DLL_LOCAL CInstanceGame : public IAddonInstance
201201
for (unsigned int i = 0; i < m_instanceData->props->proxy_dll_count; ++i)
202202
{
203203
if (m_instanceData->props->proxy_dll_paths[i] != nullptr)
204-
paths.push_back(m_instanceData->props->proxy_dll_paths[i]);
204+
paths.emplace_back(m_instanceData->props->proxy_dll_paths[i]);
205205
}
206206
return !paths.empty();
207207
}
@@ -223,7 +223,7 @@ class ATTR_DLL_LOCAL CInstanceGame : public IAddonInstance
223223
for (unsigned int i = 0; i < m_instanceData->props->resource_directory_count; ++i)
224224
{
225225
if (m_instanceData->props->resource_directories[i] != nullptr)
226-
dirs.push_back(m_instanceData->props->resource_directories[i]);
226+
dirs.emplace_back(m_instanceData->props->resource_directories[i]);
227227
}
228228
return !dirs.empty();
229229
}
@@ -269,7 +269,7 @@ class ATTR_DLL_LOCAL CInstanceGame : public IAddonInstance
269269
for (unsigned int i = 0; i < m_instanceData->props->extension_count; ++i)
270270
{
271271
if (m_instanceData->props->extensions[i] != nullptr)
272-
extensions.push_back(m_instanceData->props->extensions[i]);
272+
extensions.emplace_back(m_instanceData->props->extensions[i]);
273273
}
274274
return !extensions.empty();
275275
}
@@ -1079,7 +1079,7 @@ class ATTR_DLL_LOCAL CInstanceGame : public IAddonInstance
10791079
for (size_t i = 0; i < urlCount; ++i)
10801080
{
10811081
if (urls[i] != nullptr)
1082-
urlList.push_back(urls[i]);
1082+
urlList.emplace_back(urls[i]);
10831083
}
10841084

10851085
return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
@@ -1165,7 +1165,7 @@ class ATTR_DLL_LOCAL CInstanceGame : public IAddonInstance
11651165

11661166
std::vector<GameControllerLayout> controllerList;
11671167
for (unsigned int i = 0; i < controller_count; ++i)
1168-
controllerList.push_back(controllers[i]);
1168+
controllerList.emplace_back(controllers[i]);
11691169

11701170
static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
11711171
->SetControllerLayouts(controllerList);

xbmc/addons/settings/AddonSettings.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ bool CAddonSettings::Load(const CXBMCTinyXML& doc)
350350
settingValue = setting->FirstChild()->ValueStr();
351351

352352
// add the setting to the map
353-
settingValues.emplace(std::make_pair(settingId, settingValue));
353+
settingValues.emplace(settingId, settingValue);
354354
};
355355

356356
// check if there were any setting values without a definition
@@ -1106,7 +1106,7 @@ SettingPtr CAddonSettings::InitializeFromOldSettingSelect(
11061106

11071107
StringSettingOptions options;
11081108
for (const auto& value : values)
1109-
options.push_back(StringSettingOption(value, value));
1109+
options.emplace_back(value, value);
11101110
settingString->SetOptions(options);
11111111

11121112
setting = settingString;
@@ -1119,8 +1119,7 @@ SettingPtr CAddonSettings::InitializeFromOldSettingSelect(
11191119

11201120
TranslatableIntegerSettingOptions options;
11211121
for (uint32_t i = 0; i < values.size(); ++i)
1122-
options.push_back(TranslatableIntegerSettingOption(
1123-
static_cast<int>(strtol(values[i].c_str(), nullptr, 0)), i));
1122+
options.emplace_back(static_cast<int>(strtol(values[i].c_str(), nullptr, 0)), i);
11241123
settingInt->SetTranslatableOptions(options);
11251124

11261125
setting = settingInt;
@@ -1263,7 +1262,7 @@ SettingPtr CAddonSettings::InitializeFromOldSettingEnums(
12631262
if (settingEntries.size() > i)
12641263
value = static_cast<int>(strtol(settingEntries[i].c_str(), nullptr, 0));
12651264

1266-
options.push_back(IntegerSettingOption(label, value));
1265+
options.emplace_back(label, value);
12671266
}
12681267

12691268
settingInt->SetOptions(options);
@@ -1278,7 +1277,7 @@ SettingPtr CAddonSettings::InitializeFromOldSettingEnums(
12781277
if (settingEntries.size() > i)
12791278
value = static_cast<int>(strtol(settingEntries[i].c_str(), nullptr, 0));
12801279

1281-
options.push_back(TranslatableIntegerSettingOption(label, value));
1280+
options.emplace_back(label, value);
12821281
}
12831282

12841283
settingInt->SetTranslatableOptions(options);
@@ -1306,7 +1305,7 @@ SettingPtr CAddonSettings::InitializeFromOldSettingEnums(
13061305
if (settingEntries.size() > i)
13071306
value = settingEntries[i];
13081307

1309-
options.push_back(StringSettingOption(value, value));
1308+
options.emplace_back(value, value);
13101309
}
13111310

13121311
settingString->SetOptions(options);
@@ -1321,7 +1320,7 @@ SettingPtr CAddonSettings::InitializeFromOldSettingEnums(
13211320
if (settingEntries.size() > i)
13221321
value = settingEntries[i];
13231322

1324-
options.push_back(std::make_pair(label, value));
1323+
options.emplace_back(label, value);
13251324
}
13261325

13271326
settingString->SetTranslatableOptions(options);

xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ void CActiveAESink::EnumerateOutputDevices(AEDeviceList &devices, bool passthrou
872872
if (!devInfo.m_displayNameExtra.empty())
873873
ss << ", " << devInfo.m_displayNameExtra;
874874

875-
devices.push_back(AEDevice(ss.str(), device));
875+
devices.emplace_back(ss.str(), device);
876876
}
877877
}
878878
}

xbmc/cores/AudioEngine/Sinks/osx/AEDeviceEnumerationOSX.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ CADeviceList AEDeviceEnumerationOSX::GetDeviceInfoList() const
220220
deviceInfo.m_deviceName = getDeviceNameForStream(streamIdx) + ":source" + sourceIdxStr.str();
221221
deviceInfo.m_displayNameExtra = m_caDevice.GetDataSourceName(sourceList[sourceIdx]);
222222
devInstance.sourceId = sourceList[sourceIdx];
223-
list.push_back(std::make_pair(devInstance, deviceInfo));
223+
list.emplace_back(devInstance, deviceInfo);
224224
}
225225
}
226226
else
227-
list.push_back(std::make_pair(devInstance, deviceInfo));
227+
list.emplace_back(devInstance, deviceInfo);
228228
}
229229
return list;
230230
}

xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ bool CDemuxMultiSource::Open(const std::shared_ptr<CDVDInputStream>& pInput)
138138

139139
m_demuxerMap[demuxer->GetDemuxerId()] = demuxer;
140140
m_DemuxerToInputStreamMap[demuxer] = *iter;
141-
m_demuxerQueue.push(std::make_pair(-1.0, demuxer));
141+
m_demuxerQueue.emplace(-1.0, demuxer);
142142
++iter;
143143
}
144144
}
@@ -175,7 +175,7 @@ DemuxPacket* CDemuxMultiSource::Read()
175175
readTime = packet->dts;
176176
else
177177
readTime = packet->pts;
178-
m_demuxerQueue.push(std::make_pair(readTime, currentDemuxer));
178+
m_demuxerQueue.emplace(readTime, currentDemuxer);
179179
}
180180
else
181181
{
@@ -188,7 +188,7 @@ DemuxPacket* CDemuxMultiSource::Read()
188188
__FUNCTION__, CURL::GetRedacted(currentDemuxer->GetFileName()));
189189
}
190190
else //maybe add an error counter?
191-
m_demuxerQueue.push(std::make_pair(-1.0, currentDemuxer));
191+
m_demuxerQueue.emplace(-1.0, currentDemuxer);
192192
}
193193
}
194194

@@ -203,7 +203,7 @@ bool CDemuxMultiSource::SeekTime(double time, bool backwards, double* startpts)
203203
{
204204
if (iter.second->SeekTime(time, false, startpts))
205205
{
206-
demuxerQueue.push(std::make_pair(*startpts, iter.second));
206+
demuxerQueue.emplace(*startpts, iter.second);
207207
CLog::Log(LOGDEBUG, "{} - starting demuxer from: {:f}", __FUNCTION__, time);
208208
ret = true;
209209
}

xbmc/cores/VideoPlayer/VideoPlayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4832,7 +4832,7 @@ void CVideoPlayer::UpdatePlayState(double timeout)
48324832
{
48334833
std::string name;
48344834
pChapter->GetChapterName(name, i + 1);
4835-
state.chapters.push_back(make_pair(name, pChapter->GetChapterPos(i + 1)));
4835+
state.chapters.emplace_back(name, pChapter->GetChapterPos(i + 1));
48364836
}
48374837
}
48384838
CServiceBroker::GetDataCacheCore().SetChapters(state.chapters);

xbmc/dialogs/GUIDialogBusy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void CGUIDialogBusy::DoProcess(unsigned int currentTime, CDirtyRegionList &dirty
127127
{
128128
bool visible = CServiceBroker::GetGUI()->GetWindowManager().IsModalDialogTopmost(WINDOW_DIALOG_BUSY);
129129
if(!visible && m_bLastVisible)
130-
dirtyregions.push_back(CDirtyRegion(m_renderRegion));
130+
dirtyregions.emplace_back(m_renderRegion);
131131
m_bLastVisible = visible;
132132

133133
CGUIDialog::DoProcess(currentTime, dirtyregions);

0 commit comments

Comments
 (0)