Skip to content

Commit

Permalink
[clang-tidy] Apply performance-inefficient-vector-operation fixes.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Karl Wiberg <[email protected]>
Cr-Commit-Position: refs/heads/master@{#26442}
  • Loading branch information
MirkoBonadei authored and Commit Bot committed Jan 29, 2019
1 parent 949f0fd commit 649a4c2
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions modules/audio_mixer/audio_mixer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions modules/remote_bitrate_estimator/test/bwe_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
1 change: 1 addition & 0 deletions pc/media_session_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions pc/peer_connection_bundle_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
1 change: 1 addition & 0 deletions pc/peer_connection_media_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions pc/rtc_stats_traversal_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
4 changes: 4 additions & 0 deletions pc/rtp_sender_receiver_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down
1 change: 1 addition & 0 deletions rtc_base/bitrate_allocation_strategy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions rtc_base/fake_ssl_identity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 649a4c2

Please sign in to comment.