Skip to content

Commit f593574

Browse files
committed
Add vector space reservation whenever it is possible
1 parent 812fc59 commit f593574

5 files changed

Lines changed: 15 additions & 0 deletions

File tree

DeviceInfo/DeviceInfoImplementation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ namespace Plugin {
7474
uint32_t DeviceInfoImplementation::AudioOutputs(Exchange::IDeviceAudioCapabilities::IAudioOutputIterator*& audioOutputs) const
7575
{
7676
AudioOutputList audioOutputList;
77+
audioOutputList.reserve(_audioOutputMap.size());
7778

7879
std::transform(_audioOutputMap.begin(), _audioOutputMap.end(), std::back_inserter(audioOutputList),
7980
[](decltype(_audioOutputMap)::value_type const &pair) {
@@ -114,6 +115,7 @@ namespace Plugin {
114115
uint32_t DeviceInfoImplementation::VideoOutputs(Exchange::IDeviceVideoCapabilities::IVideoOutputIterator*& videoOutputs) const
115116
{
116117
VideoOutputList videoOutputList;
118+
videoOutputList.reserve(_videoOutputMap.size());
117119

118120
std::transform(_videoOutputMap.begin(), _videoOutputMap.end(), std::back_inserter(videoOutputList),
119121
[](decltype(_videoOutputMap)::value_type const &pair) {

DisplayInfo/DeviceSettings/PlatformImplementation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,8 @@ class DisplayInfoImplementation :
585585
uint32_t Colorimetry(IColorimetryIterator*& colorimetry /* @out */) const override
586586
{
587587
std::vector<Exchange::IDisplayProperties::ColorimetryType> colorimetryCaps;
588+
colorimetryCaps.reserve(8);
589+
588590
vector<uint8_t> edidVec;
589591
uint32_t ret = GetEdidBytes(edidVec);
590592
if (ret == Core::ERROR_NONE)
@@ -666,6 +668,7 @@ class DisplayInfoImplementation :
666668
uint32_t TVCapabilities(IHDRIterator*& type /* out */) const override
667669
{
668670
std::vector<Exchange::IHDRProperties::HDRType> hdrCapabilities;
671+
hdrCapabilities.reserve(6);
669672

670673
int capabilities = static_cast<int>(dsHDRSTANDARD_NONE);
671674
try
@@ -700,6 +703,7 @@ class DisplayInfoImplementation :
700703
uint32_t STBCapabilities(IHDRIterator*& type /* out */) const override
701704
{
702705
std::vector<Exchange::IHDRProperties::HDRType> hdrCapabilities;
706+
hdrCapabilities.reserve(6);
703707

704708
int capabilities = static_cast<int>(dsHDRSTANDARD_NONE);
705709
try

PlayerInfo/DeviceSettings/PlatformImplementation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch
459459
{"audio/x-vorbis", Exchange::IPlayerProperties::AUDIO_VORBIS_OGG},
460460
{"audio/x-wav", Exchange::IPlayerProperties::AUDIO_WAV},
461461
};
462+
_audioCodecs.reserve(audioCaps.size());
463+
462464
if (GstUtils::GstRegistryCheckElementsForMediaTypes(audioCaps, _audioCodecs) != true) {
463465
TRACE(Trace::Warning, (_T("There is no Audio Codec support available")));
464466
}
@@ -477,6 +479,8 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch
477479
{"video/x-vp9", Exchange::IPlayerProperties::VideoCodec::VIDEO_VP9},
478480
{"video/x-vp10", Exchange::IPlayerProperties::VideoCodec::VIDEO_VP10}
479481
};
482+
_videoCodecs.reserve(videoCaps.size());
483+
480484
if (GstUtils::GstRegistryCheckElementsForMediaTypes(videoCaps, _videoCodecs) != true) {
481485
TRACE(Trace::Warning, (_T("There is no Video Codec support available")));
482486
}

PlayerInfo/GStreamer/PlatformImplementation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties {
170170
{"audio/x-vorbis", Exchange::IPlayerProperties::AudioCodec::AUDIO_VORBIS_OGG},
171171
{"audio/x-wav", Exchange::IPlayerProperties::AudioCodec::AUDIO_WAV},
172172
};
173+
_audioCodecs.reserve(audioCaps.size());
174+
173175
if (GstUtils::GstRegistryCheckElementsForMediaTypes(audioCaps, _audioCodecs) != true) {
174176
TRACE(Trace::Warning, (_T("There is no Audio Codec support available")));
175177
}
@@ -185,6 +187,8 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties {
185187
{"video/x-vp9", Exchange::IPlayerProperties::VideoCodec::VIDEO_VP9},
186188
{"video/x-vp10", Exchange::IPlayerProperties::VideoCodec::VIDEO_VP10}
187189
};
190+
_videoCodecs.reserve(videoCaps.size());
191+
188192
if (GstUtils::GstRegistryCheckElementsForMediaTypes(videoCaps, _videoCodecs) != true) {
189193
TRACE(Trace::Warning, (_T("There is no Video Codec support available")));
190194
}

WebKitBrowser/WebKitBrowser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ namespace Plugin {
332332
array.FromString(languagesList);
333333

334334
std::vector<string> list;
335+
list.reserve(array.Length());
335336
auto iterator = array.Elements();
336337

337338
while (iterator.Next() == true) {

0 commit comments

Comments
 (0)