diff options
author | Rechi <Rechi@users.noreply.github.com> | 2020-10-30 18:53:28 +0000 |
---|---|---|
committer | Rechi <Rechi@users.noreply.github.com> | 2020-10-30 18:53:28 +0000 |
commit | 5466b730fdc6ad591f6292e0a37efd50f53ecb40 (patch) | |
tree | ea51c26fdd9d45f1c2bd5009ea1b39b75e8b0eda | |
parent | bb8e648cbfedc0db482d1e3983f22378330fd0b3 (diff) |
[clang-tidy] performance-inefficient-vector-operation
-rw-r--r-- | xbmc/addons/gui/GUIDialogAddonInfo.cpp | 1 | ||||
-rw-r--r-- | xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h | 2 | ||||
-rw-r--r-- | xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.cpp | 1 | ||||
-rw-r--r-- | xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCC.cpp | 1 | ||||
-rw-r--r-- | xbmc/cores/VideoPlayer/VideoRenderers/RenderFactory.cpp | 1 | ||||
-rw-r--r-- | xbmc/input/joysticks/keymaps/KeyHandler.cpp | 1 | ||||
-rw-r--r-- | xbmc/interfaces/json-rpc/JSONServiceDescription.cpp | 2 | ||||
-rw-r--r-- | xbmc/peripherals/devices/Peripheral.cpp | 1 | ||||
-rw-r--r-- | xbmc/pictures/GUIWindowSlideShow.cpp | 1 | ||||
-rw-r--r-- | xbmc/pictures/PictureThumbLoader.cpp | 1 | ||||
-rw-r--r-- | xbmc/platform/android/network/NetworkAndroid.cpp | 1 | ||||
-rw-r--r-- | xbmc/settings/AdvancedSettings.cpp | 1 |
12 files changed, 14 insertions, 0 deletions
diff --git a/xbmc/addons/gui/GUIDialogAddonInfo.cpp b/xbmc/addons/gui/GUIDialogAddonInfo.cpp index 04323c510a..a51947d060 100644 --- a/xbmc/addons/gui/GUIDialogAddonInfo.cpp +++ b/xbmc/addons/gui/GUIDialogAddonInfo.cpp @@ -341,6 +341,7 @@ void CGUIDialogAddonInfo::OnSelectVersion() // get all compatible versions of an addon-id regardless of their origin CServiceBroker::GetAddonMgr().GetCompatibleVersions(processAddonId, compatibleVersions); + versions.reserve(compatibleVersions.size()); for (const auto& compatibleVersion : compatibleVersions) versions.emplace_back( std::make_pair(compatibleVersion->Version(), compatibleVersion->Origin())); diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h b/xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h index cf7366a9bb..9e0598353b 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h @@ -382,6 +382,7 @@ public: if (res) { std::vector<std::string> vecReturn; + vecReturn.reserve(numValues); for (int i = 0; i < numValues; ++i) { vecReturn.emplace_back(res[i]); @@ -2324,6 +2325,7 @@ public: if (res) { std::vector<std::string> vecReturn; + vecReturn.reserve(numValues); for (int i = 0; i < numValues; ++i) { vecReturn.emplace_back(res[i]); diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.cpp index 4c7e1e040d..d883ecb6a5 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.cpp @@ -133,6 +133,7 @@ std::vector<std::string> CDVDFactoryCodec::GetHWAccels() CSingleLock lock(videoCodecSection); std::vector<std::string> ret; + ret.reserve(m_hwAccels.size()); for (auto &hwaccel : m_hwAccels) { ret.push_back(hwaccel.first); diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCC.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCC.cpp index a0deafb05c..ce374981cd 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCC.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxCC.cpp @@ -114,6 +114,7 @@ std::vector<CDemuxStream*> CDVDDemuxCC::GetStreams() const std::vector<CDemuxStream*> streams; int num = GetNrOfStreams(); + streams.reserve(num); for (int i = 0; i < num; ++i) { streams.push_back(const_cast<CDemuxStreamSubtitle*>(&m_streams[i])); diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/RenderFactory.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/RenderFactory.cpp index 2421e33bda..8c3127b0d3 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/RenderFactory.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/RenderFactory.cpp @@ -33,6 +33,7 @@ std::vector<std::string> CRendererFactory::GetRenderers() CSingleLock lock(renderSection); std::vector<std::string> ret; + ret.reserve(m_renderers.size()); for (auto &renderer : m_renderers) { ret.push_back(renderer.first); diff --git a/xbmc/input/joysticks/keymaps/KeyHandler.cpp b/xbmc/input/joysticks/keymaps/KeyHandler.cpp index 5df45e2c23..cd0f30aafd 100644 --- a/xbmc/input/joysticks/keymaps/KeyHandler.cpp +++ b/xbmc/input/joysticks/keymaps/KeyHandler.cpp @@ -109,6 +109,7 @@ bool CKeyHandler::OnAnalogMotion(float magnitude, unsigned int motionTimeMs) { std::vector<const KeymapAction*> allActions; + allActions.reserve(actions.size()); for (const auto& action : actions) allActions.emplace_back(&action); diff --git a/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp b/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp index 7c0055343a..1b21fa6f23 100644 --- a/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp +++ b/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp @@ -1711,6 +1711,7 @@ bool CJSONServiceDescription::AddEnum(const std::string &name, const std::vector bool CJSONServiceDescription::AddEnum(const std::string &name, const std::vector<std::string> &values) { std::vector<CVariant> enums; + enums.reserve(values.size()); for (const auto& it : values) enums.emplace_back(it); @@ -1720,6 +1721,7 @@ bool CJSONServiceDescription::AddEnum(const std::string &name, const std::vector bool CJSONServiceDescription::AddEnum(const std::string &name, const std::vector<int> &values) { std::vector<CVariant> enums; + enums.reserve(values.size()); for (const auto& it : values) enums.emplace_back(it); diff --git a/xbmc/peripherals/devices/Peripheral.cpp b/xbmc/peripherals/devices/Peripheral.cpp index 22fe9f509a..6b07065038 100644 --- a/xbmc/peripherals/devices/Peripheral.cpp +++ b/xbmc/peripherals/devices/Peripheral.cpp @@ -208,6 +208,7 @@ std::vector<std::shared_ptr<CSetting>> CPeripheral::GetSettings(void) const sort(tmpSettings.begin(), tmpSettings.end(), SortBySettingsOrder()); std::vector<std::shared_ptr<CSetting>> settings; + settings.reserve(tmpSettings.size()); for (const auto& it : tmpSettings) settings.push_back(it.m_setting); return settings; diff --git a/xbmc/pictures/GUIWindowSlideShow.cpp b/xbmc/pictures/GUIWindowSlideShow.cpp index f19f64ab19..767cefd51c 100644 --- a/xbmc/pictures/GUIWindowSlideShow.cpp +++ b/xbmc/pictures/GUIWindowSlideShow.cpp @@ -1328,6 +1328,7 @@ void CGUIWindowSlideShow::RunSlideShow(std::vector<std::string> paths, int start if (dialog) { std::vector<CFileItemPtr> items; + items.reserve(paths.size()); for (const auto& path : paths) items.push_back(std::make_shared<CFileItem>(CTextureUtils::GetWrappedImageURL(path), false)); diff --git a/xbmc/pictures/PictureThumbLoader.cpp b/xbmc/pictures/PictureThumbLoader.cpp index da066c86a2..25163c22e2 100644 --- a/xbmc/pictures/PictureThumbLoader.cpp +++ b/xbmc/pictures/PictureThumbLoader.cpp @@ -226,6 +226,7 @@ void CPictureThumbLoader::ProcessFoldersAndArchives(CFileItem *pItem) // ok, now we've got the files to get the thumbs from, lets create it... // we basically load the 4 images and combine them std::vector<std::string> files; + files.reserve(4); for (int thumb = 0; thumb < 4; thumb++) files.push_back(items[thumb]->GetPath()); std::string thumb = CTextureUtils::GetWrappedImageURL(pItem->GetPath(), "picturefolder"); diff --git a/xbmc/platform/android/network/NetworkAndroid.cpp b/xbmc/platform/android/network/NetworkAndroid.cpp index b97afcabcf..810731032c 100644 --- a/xbmc/platform/android/network/NetworkAndroid.cpp +++ b/xbmc/platform/android/network/NetworkAndroid.cpp @@ -38,6 +38,7 @@ std::vector<std::string> CNetworkInterfaceAndroid::GetNameServers() std::vector<std::string> ret; CJNIList<CJNIInetAddress> lia = m_lp.getDnsServers(); + ret.reserve(lia.size()); for (int i=0; i < lia.size(); ++i) { ret.push_back(lia.get(i).getHostAddress()); diff --git a/xbmc/settings/AdvancedSettings.cpp b/xbmc/settings/AdvancedSettings.cpp index 796bf99081..03280ed6a5 100644 --- a/xbmc/settings/AdvancedSettings.cpp +++ b/xbmc/settings/AdvancedSettings.cpp @@ -1442,6 +1442,7 @@ void CAdvancedSettings::MigrateOldArtSettings() thumbs2.emplace_back(it); } std::vector<CVariant> thumbs; + thumbs.reserve(thumbs2.size()); for (const auto& it : thumbs2) thumbs.emplace_back(it); settings->SetList(CSettings::SETTING_MUSICLIBRARY_MUSICTHUMBS, thumbs); |