[clang-tidy] Apply performance-inefficient-vector-operation fixes.
This CL applies clang-tidy's performance-inefficient-vector-operation [1] on the WebRTC codebase. All changes in this CL are automatically generated by both clang-tidy and 'git cl format'. [1] - https://clang.llvm.org/extra/clang-tidy/checks/performance-inefficient-vector-operation.html Bug: webrtc:10252 Change-Id: I824caab2a5746036852e00d714b89aa5ec030ee3 Reviewed-on: https://webrtc-review.googlesource.com/c/120052 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26442}
This commit is contained in:
parent
949f0fdc10
commit
649a4c2ea3
@ -116,6 +116,7 @@ TEST(BuiltinAudioEncoderFactoryTest, SupportsTheExpectedFormats) {
|
||||
|
||||
const std::vector<SdpAudioFormat> supported_formats = [&specs] {
|
||||
std::vector<SdpAudioFormat> formats;
|
||||
formats.reserve(specs.size());
|
||||
for (const auto& spec : specs) {
|
||||
formats.push_back(spec.format);
|
||||
}
|
||||
|
||||
@ -122,6 +122,7 @@ int main(int argc, char* argv[]) {
|
||||
const std::vector<std::string> input_files = parse_input_files();
|
||||
std::vector<webrtc::test::FilePlayingSource> sources;
|
||||
const int num_channels = FLAG_stereo ? 2 : 1;
|
||||
sources.reserve(input_files.size());
|
||||
for (const auto& input_file : input_files) {
|
||||
sources.emplace_back(input_file);
|
||||
}
|
||||
|
||||
@ -329,6 +329,7 @@ void BweTest::RunFairnessTest(BandwidthEstimatorType bwe_type,
|
||||
jitter.SetMaxJitter(max_jitter_ms);
|
||||
|
||||
std::vector<RateCounterFilter*> rate_counters;
|
||||
rate_counters.reserve(media_flow_ids.size());
|
||||
for (int flow : media_flow_ids) {
|
||||
rate_counters.push_back(
|
||||
new RateCounterFilter(&uplink_, flow, "Receiver", bwe_names[bwe_type]));
|
||||
|
||||
@ -72,6 +72,7 @@ TEST_F(MetricRecorderTest, VariableDelayPackets) {
|
||||
const int kNumPackets = 1000;
|
||||
|
||||
std::vector<int64_t> delays_ms;
|
||||
delays_ms.reserve(kNumPackets);
|
||||
for (int i = 0; i < kNumPackets; ++i) {
|
||||
delays_ms.push_back(static_cast<int64_t>(i + 1));
|
||||
}
|
||||
|
||||
@ -266,6 +266,7 @@ static void AddRtxCodec(const VideoCodec& rtx_codec,
|
||||
template <class T>
|
||||
static std::vector<std::string> GetCodecNames(const std::vector<T>& codecs) {
|
||||
std::vector<std::string> codec_names;
|
||||
codec_names.reserve(codecs.size());
|
||||
for (const auto& codec : codecs) {
|
||||
codec_names.push_back(codec.name);
|
||||
}
|
||||
|
||||
@ -282,6 +282,7 @@ SdpContentMutator RemoveRtcpMux() {
|
||||
std::vector<int> GetCandidateComponents(
|
||||
const std::vector<IceCandidateInterface*> candidates) {
|
||||
std::vector<int> components;
|
||||
components.reserve(candidates.size());
|
||||
for (auto* candidate : candidates) {
|
||||
components.push_back(candidate->candidate().component());
|
||||
}
|
||||
|
||||
@ -201,6 +201,7 @@ TEST_P(PeerConnectionMediaTest,
|
||||
std::vector<std::string> GetIds(
|
||||
const std::vector<cricket::StreamParams>& streams) {
|
||||
std::vector<std::string> ids;
|
||||
ids.reserve(streams.size());
|
||||
for (const auto& stream : streams) {
|
||||
ids.push_back(stream.id);
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ class RTCStatsTraversalTest : public testing::Test {
|
||||
|
||||
void TakeReferencedStats(std::vector<const RTCStats*> start_nodes) {
|
||||
std::vector<std::string> start_ids;
|
||||
start_ids.reserve(start_nodes.size());
|
||||
for (const RTCStats* start_node : start_nodes) {
|
||||
start_ids.push_back(start_node->id());
|
||||
}
|
||||
|
||||
@ -203,6 +203,7 @@ class RtpSenderReceiverTest : public testing::Test,
|
||||
void CreateVideoRtpSenderWithSimulcast(
|
||||
int num_layers = kVideoSimulcastLayerCount) {
|
||||
std::vector<uint32_t> ssrcs;
|
||||
ssrcs.reserve(num_layers);
|
||||
for (int i = 0; i < num_layers; ++i)
|
||||
ssrcs.push_back(kVideoSsrcSimulcast + i);
|
||||
cricket::StreamParams stream_params =
|
||||
@ -260,6 +261,7 @@ class RtpSenderReceiverTest : public testing::Test,
|
||||
std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams = {},
|
||||
int num_layers = kVideoSimulcastLayerCount) {
|
||||
std::vector<uint32_t> ssrcs;
|
||||
ssrcs.reserve(num_layers);
|
||||
for (int i = 0; i < num_layers; ++i)
|
||||
ssrcs.push_back(kVideoSsrcSimulcast + i);
|
||||
cricket::StreamParams stream_params =
|
||||
@ -943,6 +945,7 @@ TEST_F(RtpSenderReceiverTest, VideoSenderInitParametersMovedAfterNegotiation) {
|
||||
|
||||
// Simulate the setLocalDescription call
|
||||
std::vector<uint32_t> ssrcs;
|
||||
ssrcs.reserve(2);
|
||||
for (int i = 0; i < 2; ++i)
|
||||
ssrcs.push_back(kVideoSsrcSimulcast + i);
|
||||
cricket::StreamParams stream_params =
|
||||
@ -978,6 +981,7 @@ TEST_F(RtpSenderReceiverTest,
|
||||
// Simulate the setLocalDescription call as if the user used SDP munging
|
||||
// to enable simulcast
|
||||
std::vector<uint32_t> ssrcs;
|
||||
ssrcs.reserve(2);
|
||||
for (int i = 0; i < 2; ++i)
|
||||
ssrcs.push_back(kVideoSsrcSimulcast + i);
|
||||
cricket::StreamParams stream_params =
|
||||
|
||||
@ -45,6 +45,7 @@ const int kTransmissionMaxBitrateMultiplier = 2;
|
||||
std::vector<uint32_t> BitrateAllocationStrategy::SetAllBitratesToMinimum(
|
||||
const std::vector<BitrateAllocationStrategy::TrackConfig>& track_configs) {
|
||||
std::vector<uint32_t> track_allocations;
|
||||
track_allocations.reserve(track_configs.size());
|
||||
for (const auto& track_config : track_configs) {
|
||||
track_allocations.push_back(track_config.min_bitrate_bps);
|
||||
}
|
||||
|
||||
@ -75,6 +75,7 @@ FakeSSLIdentity::FakeSSLIdentity(const std::string& pem_string)
|
||||
|
||||
FakeSSLIdentity::FakeSSLIdentity(const std::vector<std::string>& pem_strings) {
|
||||
std::vector<std::unique_ptr<SSLCertificate>> certs;
|
||||
certs.reserve(pem_strings.size());
|
||||
for (const std::string& pem_string : pem_strings) {
|
||||
certs.push_back(absl::make_unique<FakeSSLCertificate>(pem_string));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user