From 812fc5965641eb7e1b27a0af91dd539483db3332 Mon Sep 17 00:00:00 2001 From: VeithMetro Date: Fri, 12 Dec 2025 10:01:29 +0100 Subject: [PATCH 1/3] Change some lists to vectors if they are used to created RPC::IteratorType --- DeviceInfo/DeviceInfoImplementation.cpp | 2 +- DeviceInfo/DeviceInfoImplementation.h | 4 ++-- DisplayInfo/DeviceSettings/PlatformImplementation.cpp | 6 +++--- MessageControl/MessageControl.h | 2 +- PlayerInfo/DeviceSettings/PlatformImplementation.cpp | 4 ++-- PlayerInfo/GStreamer/PlatformImplementation.cpp | 4 ++-- WebKitBrowser/WebKitBrowser.cpp | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/DeviceInfo/DeviceInfoImplementation.cpp b/DeviceInfo/DeviceInfoImplementation.cpp index 4bf234ad..c3bb51b8 100644 --- a/DeviceInfo/DeviceInfoImplementation.cpp +++ b/DeviceInfo/DeviceInfoImplementation.cpp @@ -75,7 +75,7 @@ namespace Plugin { { AudioOutputList audioOutputList; - std::transform(_audioOutputMap.begin(), _audioOutputMap.end(), std::front_inserter(audioOutputList), + std::transform(_audioOutputMap.begin(), _audioOutputMap.end(), std::back_inserter(audioOutputList), [](decltype(_audioOutputMap)::value_type const &pair) { return pair.first; }); diff --git a/DeviceInfo/DeviceInfoImplementation.h b/DeviceInfo/DeviceInfoImplementation.h index a1de13f3..6c10b664 100644 --- a/DeviceInfo/DeviceInfoImplementation.h +++ b/DeviceInfo/DeviceInfoImplementation.h @@ -151,7 +151,7 @@ namespace Plugin { std::list MS12Profiles; }; using AudioOutputMap = std::map; - using AudioOutputList = std::list; + using AudioOutputList = std::vector; using AudioOutputIteratorImplementation = RPC::IteratorType; struct VideoOutputCapability { @@ -160,7 +160,7 @@ namespace Plugin { IDeviceVideoCapabilities::CopyProtection CopyProtection; }; using VideoOutputMap = std::map; - using VideoOutputList = std::list; + using VideoOutputList = std::vector; using VideoOutputIteratorImplementation = RPC::IteratorType; public: diff --git a/DisplayInfo/DeviceSettings/PlatformImplementation.cpp b/DisplayInfo/DeviceSettings/PlatformImplementation.cpp index eebe80c6..9724000f 100644 --- a/DisplayInfo/DeviceSettings/PlatformImplementation.cpp +++ b/DisplayInfo/DeviceSettings/PlatformImplementation.cpp @@ -584,7 +584,7 @@ class DisplayInfoImplementation : uint32_t Colorimetry(IColorimetryIterator*& colorimetry /* @out */) const override { - std::list colorimetryCaps; + std::vector colorimetryCaps; vector edidVec; uint32_t ret = GetEdidBytes(edidVec); if (ret == Core::ERROR_NONE) @@ -665,7 +665,7 @@ class DisplayInfoImplementation : // @return HDRType: array of HDR formats uint32_t TVCapabilities(IHDRIterator*& type /* out */) const override { - std::list hdrCapabilities; + std::vector hdrCapabilities; int capabilities = static_cast(dsHDRSTANDARD_NONE); try @@ -699,7 +699,7 @@ class DisplayInfoImplementation : // @return HDRType: array of HDR formats uint32_t STBCapabilities(IHDRIterator*& type /* out */) const override { - std::list hdrCapabilities; + std::vector hdrCapabilities; int capabilities = static_cast(dsHDRSTANDARD_NONE); try diff --git a/MessageControl/MessageControl.h b/MessageControl/MessageControl.h index 2e33ad44..1d081e5b 100644 --- a/MessageControl/MessageControl.h +++ b/MessageControl/MessageControl.h @@ -432,7 +432,7 @@ namespace Plugin { Core::hresult Controls(const string& module, Exchange::IMessageControl::IControlIterator*& controls) const override { - std::list list; + std::vector list; Messaging::MessageUnit::Iterator index; _client.Controls(index, module); diff --git a/PlayerInfo/DeviceSettings/PlatformImplementation.cpp b/PlayerInfo/DeviceSettings/PlatformImplementation.cpp index 72993d95..775efff1 100644 --- a/PlayerInfo/DeviceSettings/PlatformImplementation.cpp +++ b/PlayerInfo/DeviceSettings/PlatformImplementation.cpp @@ -483,8 +483,8 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch } private: - std::list _audioCodecs; - std::list _videoCodecs; + std::vector _audioCodecs; + std::vector _videoCodecs; std::map _resolutions = { {"480i24", RESOLUTION_480I24}, diff --git a/PlayerInfo/GStreamer/PlatformImplementation.cpp b/PlayerInfo/GStreamer/PlatformImplementation.cpp index 3794ad17..5f2abd2d 100644 --- a/PlayerInfo/GStreamer/PlatformImplementation.cpp +++ b/PlayerInfo/GStreamer/PlatformImplementation.cpp @@ -191,8 +191,8 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties { } private: - std::list _audioCodecs; - std::list _videoCodecs; + std::vector _audioCodecs; + std::vector _videoCodecs; #if DOLBY_SUPPORT Exchange::Dolby::IOutput* _dolbyOut; #endif diff --git a/WebKitBrowser/WebKitBrowser.cpp b/WebKitBrowser/WebKitBrowser.cpp index 2c94191c..f073e667 100644 --- a/WebKitBrowser/WebKitBrowser.cpp +++ b/WebKitBrowser/WebKitBrowser.cpp @@ -331,7 +331,7 @@ namespace Plugin { Core::JSON::ArrayType array; array.FromString(languagesList); - std::list list; + std::vector list; auto iterator = array.Elements(); while (iterator.Next() == true) { From f59357466cd29dc5d78d897a4ec8b778cfaac609 Mon Sep 17 00:00:00 2001 From: VeithMetro Date: Mon, 15 Dec 2025 09:43:39 +0100 Subject: [PATCH 2/3] Add vector space reservation whenever it is possible --- DeviceInfo/DeviceInfoImplementation.cpp | 2 ++ DisplayInfo/DeviceSettings/PlatformImplementation.cpp | 4 ++++ PlayerInfo/DeviceSettings/PlatformImplementation.cpp | 4 ++++ PlayerInfo/GStreamer/PlatformImplementation.cpp | 4 ++++ WebKitBrowser/WebKitBrowser.cpp | 1 + 5 files changed, 15 insertions(+) diff --git a/DeviceInfo/DeviceInfoImplementation.cpp b/DeviceInfo/DeviceInfoImplementation.cpp index c3bb51b8..e3c016f8 100644 --- a/DeviceInfo/DeviceInfoImplementation.cpp +++ b/DeviceInfo/DeviceInfoImplementation.cpp @@ -74,6 +74,7 @@ namespace Plugin { uint32_t DeviceInfoImplementation::AudioOutputs(Exchange::IDeviceAudioCapabilities::IAudioOutputIterator*& audioOutputs) const { AudioOutputList audioOutputList; + audioOutputList.reserve(_audioOutputMap.size()); std::transform(_audioOutputMap.begin(), _audioOutputMap.end(), std::back_inserter(audioOutputList), [](decltype(_audioOutputMap)::value_type const &pair) { @@ -114,6 +115,7 @@ namespace Plugin { uint32_t DeviceInfoImplementation::VideoOutputs(Exchange::IDeviceVideoCapabilities::IVideoOutputIterator*& videoOutputs) const { VideoOutputList videoOutputList; + videoOutputList.reserve(_videoOutputMap.size()); std::transform(_videoOutputMap.begin(), _videoOutputMap.end(), std::back_inserter(videoOutputList), [](decltype(_videoOutputMap)::value_type const &pair) { diff --git a/DisplayInfo/DeviceSettings/PlatformImplementation.cpp b/DisplayInfo/DeviceSettings/PlatformImplementation.cpp index 9724000f..7c16f7b4 100644 --- a/DisplayInfo/DeviceSettings/PlatformImplementation.cpp +++ b/DisplayInfo/DeviceSettings/PlatformImplementation.cpp @@ -585,6 +585,8 @@ class DisplayInfoImplementation : uint32_t Colorimetry(IColorimetryIterator*& colorimetry /* @out */) const override { std::vector colorimetryCaps; + colorimetryCaps.reserve(8); + vector edidVec; uint32_t ret = GetEdidBytes(edidVec); if (ret == Core::ERROR_NONE) @@ -666,6 +668,7 @@ class DisplayInfoImplementation : uint32_t TVCapabilities(IHDRIterator*& type /* out */) const override { std::vector hdrCapabilities; + hdrCapabilities.reserve(6); int capabilities = static_cast(dsHDRSTANDARD_NONE); try @@ -700,6 +703,7 @@ class DisplayInfoImplementation : uint32_t STBCapabilities(IHDRIterator*& type /* out */) const override { std::vector hdrCapabilities; + hdrCapabilities.reserve(6); int capabilities = static_cast(dsHDRSTANDARD_NONE); try diff --git a/PlayerInfo/DeviceSettings/PlatformImplementation.cpp b/PlayerInfo/DeviceSettings/PlatformImplementation.cpp index 775efff1..10b796ec 100644 --- a/PlayerInfo/DeviceSettings/PlatformImplementation.cpp +++ b/PlayerInfo/DeviceSettings/PlatformImplementation.cpp @@ -459,6 +459,8 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch {"audio/x-vorbis", Exchange::IPlayerProperties::AUDIO_VORBIS_OGG}, {"audio/x-wav", Exchange::IPlayerProperties::AUDIO_WAV}, }; + _audioCodecs.reserve(audioCaps.size()); + if (GstUtils::GstRegistryCheckElementsForMediaTypes(audioCaps, _audioCodecs) != true) { TRACE(Trace::Warning, (_T("There is no Audio Codec support available"))); } @@ -477,6 +479,8 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch {"video/x-vp9", Exchange::IPlayerProperties::VideoCodec::VIDEO_VP9}, {"video/x-vp10", Exchange::IPlayerProperties::VideoCodec::VIDEO_VP10} }; + _videoCodecs.reserve(videoCaps.size()); + if (GstUtils::GstRegistryCheckElementsForMediaTypes(videoCaps, _videoCodecs) != true) { TRACE(Trace::Warning, (_T("There is no Video Codec support available"))); } diff --git a/PlayerInfo/GStreamer/PlatformImplementation.cpp b/PlayerInfo/GStreamer/PlatformImplementation.cpp index 5f2abd2d..31bf769b 100644 --- a/PlayerInfo/GStreamer/PlatformImplementation.cpp +++ b/PlayerInfo/GStreamer/PlatformImplementation.cpp @@ -170,6 +170,8 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties { {"audio/x-vorbis", Exchange::IPlayerProperties::AudioCodec::AUDIO_VORBIS_OGG}, {"audio/x-wav", Exchange::IPlayerProperties::AudioCodec::AUDIO_WAV}, }; + _audioCodecs.reserve(audioCaps.size()); + if (GstUtils::GstRegistryCheckElementsForMediaTypes(audioCaps, _audioCodecs) != true) { TRACE(Trace::Warning, (_T("There is no Audio Codec support available"))); } @@ -185,6 +187,8 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties { {"video/x-vp9", Exchange::IPlayerProperties::VideoCodec::VIDEO_VP9}, {"video/x-vp10", Exchange::IPlayerProperties::VideoCodec::VIDEO_VP10} }; + _videoCodecs.reserve(videoCaps.size()); + if (GstUtils::GstRegistryCheckElementsForMediaTypes(videoCaps, _videoCodecs) != true) { TRACE(Trace::Warning, (_T("There is no Video Codec support available"))); } diff --git a/WebKitBrowser/WebKitBrowser.cpp b/WebKitBrowser/WebKitBrowser.cpp index f073e667..2e6e7757 100644 --- a/WebKitBrowser/WebKitBrowser.cpp +++ b/WebKitBrowser/WebKitBrowser.cpp @@ -332,6 +332,7 @@ namespace Plugin { array.FromString(languagesList); std::vector list; + list.reserve(array.Length()); auto iterator = array.Elements(); while (iterator.Next() == true) { From 9aeaf106e59c5228251a0a93f50c337f2fd5167f Mon Sep 17 00:00:00 2001 From: Mateusz Daniluk <121170681+VeithMetro@users.noreply.github.com> Date: Wed, 17 Dec 2025 13:10:30 +0100 Subject: [PATCH 3/3] Reduce reserved size for HDR capabilities vectors --- DisplayInfo/DeviceSettings/PlatformImplementation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DisplayInfo/DeviceSettings/PlatformImplementation.cpp b/DisplayInfo/DeviceSettings/PlatformImplementation.cpp index 7c16f7b4..c775ffd6 100644 --- a/DisplayInfo/DeviceSettings/PlatformImplementation.cpp +++ b/DisplayInfo/DeviceSettings/PlatformImplementation.cpp @@ -668,7 +668,7 @@ class DisplayInfoImplementation : uint32_t TVCapabilities(IHDRIterator*& type /* out */) const override { std::vector hdrCapabilities; - hdrCapabilities.reserve(6); + hdrCapabilities.reserve(4); int capabilities = static_cast(dsHDRSTANDARD_NONE); try @@ -703,7 +703,7 @@ class DisplayInfoImplementation : uint32_t STBCapabilities(IHDRIterator*& type /* out */) const override { std::vector hdrCapabilities; - hdrCapabilities.reserve(6); + hdrCapabilities.reserve(4); int capabilities = static_cast(dsHDRSTANDARD_NONE); try