[clang-tidy] Apply performance-move-const-arg fixes (misc).
This CL is a manual spin-off of [1], which tried to apply clang-tidy's performance-move-const-arg [1] to the WebRTC codebase. Since there were some wrong fixes to correct, this CL lands a few different fixes, like adding a constructor overload to take an rvalue reference or remove 'const' to make std::move effective. [1] - https://webrtc-review.googlesource.com/c/src/+/120350 [2] - https://clang.llvm.org/extra/clang-tidy/checks/performance-move-const-arg.html Bug: webrtc:10252 Change-Id: I42a777247fee2cb788efcd7c2035148330056b7a Reviewed-on: https://webrtc-review.googlesource.com/c/120928 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26553}
This commit is contained in:

committed by
Commit Bot

parent
87ce874f99
commit
1c54605e77
@ -10,6 +10,8 @@
|
||||
|
||||
#include "api/audio_codecs/audio_format.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -31,6 +33,15 @@ SdpAudioFormat::SdpAudioFormat(absl::string_view name,
|
||||
num_channels(num_channels),
|
||||
parameters(param) {}
|
||||
|
||||
SdpAudioFormat::SdpAudioFormat(absl::string_view name,
|
||||
int clockrate_hz,
|
||||
size_t num_channels,
|
||||
Parameters&& param)
|
||||
: name(name),
|
||||
clockrate_hz(clockrate_hz),
|
||||
num_channels(num_channels),
|
||||
parameters(std::move(param)) {}
|
||||
|
||||
bool SdpAudioFormat::Matches(const SdpAudioFormat& o) const {
|
||||
return absl::EqualsIgnoreCase(name, o.name) &&
|
||||
clockrate_hz == o.clockrate_hz && num_channels == o.num_channels;
|
||||
|
@ -32,6 +32,10 @@ struct RTC_EXPORT SdpAudioFormat {
|
||||
int clockrate_hz,
|
||||
size_t num_channels,
|
||||
const Parameters& param);
|
||||
SdpAudioFormat(absl::string_view name,
|
||||
int clockrate_hz,
|
||||
size_t num_channels,
|
||||
Parameters&& param);
|
||||
~SdpAudioFormat();
|
||||
|
||||
// Returns true if this format is compatible with |o|. In SDP terminology:
|
||||
|
@ -587,7 +587,7 @@ int32_t ChannelSend::SendMediaTransportAudio(
|
||||
sampling_rate_hz = media_transport_sampling_frequency_;
|
||||
channel_id = media_transport_channel_id_;
|
||||
}
|
||||
const MediaTransportEncodedAudioFrame frame(
|
||||
MediaTransportEncodedAudioFrame frame(
|
||||
/*sampling_rate_hz=*/sampling_rate_hz,
|
||||
|
||||
// TODO(nisse): Timestamp and sample index are the same for all supported
|
||||
|
@ -1051,7 +1051,7 @@ bool ParsedRtcEventLog::ParseStream(
|
||||
// Since we dont need rapid lookup based on SSRC after parsing, we move the
|
||||
// packets_streams from map to vector.
|
||||
incoming_rtp_packets_by_ssrc_.reserve(incoming_rtp_packets_map_.size());
|
||||
for (const auto& kv : incoming_rtp_packets_map_) {
|
||||
for (auto& kv : incoming_rtp_packets_map_) {
|
||||
incoming_rtp_packets_by_ssrc_.emplace_back(LoggedRtpStreamIncoming());
|
||||
incoming_rtp_packets_by_ssrc_.back().ssrc = kv.first;
|
||||
incoming_rtp_packets_by_ssrc_.back().incoming_packets =
|
||||
@ -1059,7 +1059,7 @@ bool ParsedRtcEventLog::ParseStream(
|
||||
}
|
||||
incoming_rtp_packets_map_.clear();
|
||||
outgoing_rtp_packets_by_ssrc_.reserve(outgoing_rtp_packets_map_.size());
|
||||
for (const auto& kv : outgoing_rtp_packets_map_) {
|
||||
for (auto& kv : outgoing_rtp_packets_map_) {
|
||||
outgoing_rtp_packets_by_ssrc_.emplace_back(LoggedRtpStreamOutgoing());
|
||||
outgoing_rtp_packets_by_ssrc_.back().ssrc = kv.first;
|
||||
outgoing_rtp_packets_by_ssrc_.back().outgoing_packets =
|
||||
|
@ -17,8 +17,7 @@ namespace webrtc {
|
||||
const char AudioDeviceName::kDefaultDeviceId[] = "default";
|
||||
const char AudioDeviceName::kDefaultCommunicationsDeviceId[] = "communications";
|
||||
|
||||
AudioDeviceName::AudioDeviceName(const std::string device_name,
|
||||
const std::string unique_id)
|
||||
AudioDeviceName::AudioDeviceName(std::string device_name, std::string unique_id)
|
||||
: device_name(std::move(device_name)), unique_id(std::move(unique_id)) {}
|
||||
|
||||
bool AudioDeviceName::IsValid() {
|
||||
|
@ -24,7 +24,7 @@ struct AudioDeviceName {
|
||||
static const char kDefaultCommunicationsDeviceId[];
|
||||
|
||||
AudioDeviceName() = default;
|
||||
AudioDeviceName(const std::string device_name, const std::string unique_id);
|
||||
AudioDeviceName(std::string device_name, std::string unique_id);
|
||||
|
||||
~AudioDeviceName() = default;
|
||||
|
||||
|
@ -994,7 +994,7 @@ class PeerConnectionIceConfigTest : public testing::Test {
|
||||
nullptr /* cert_generator */,
|
||||
&observer_));
|
||||
EXPECT_TRUE(pc.get());
|
||||
pc_ = std::move(pc.get());
|
||||
pc_ = std::move(pc);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_ = nullptr;
|
||||
|
@ -18,8 +18,4 @@ TransportChannelStats::TransportChannelStats(const TransportChannelStats&) =
|
||||
|
||||
TransportChannelStats::~TransportChannelStats() = default;
|
||||
|
||||
TransportStats::TransportStats() = default;
|
||||
|
||||
TransportStats::~TransportStats() = default;
|
||||
|
||||
} // namespace cricket
|
||||
|
@ -39,9 +39,6 @@ typedef std::vector<TransportChannelStats> TransportChannelStatsList;
|
||||
|
||||
// Information about the stats of a transport.
|
||||
struct TransportStats {
|
||||
TransportStats();
|
||||
~TransportStats();
|
||||
|
||||
std::string transport_name;
|
||||
TransportChannelStatsList channel_stats;
|
||||
};
|
||||
|
@ -97,6 +97,7 @@ TEST(FunctionViewTest, CopyConstructor) {
|
||||
TEST(FunctionViewTest, MoveConstructorIsCopy) {
|
||||
auto f17 = [] { return 17; };
|
||||
rtc::FunctionView<int()> fv1(f17);
|
||||
// NOLINTNEXTLINE(performance-move-const-arg)
|
||||
rtc::FunctionView<int()> fv2(std::move(fv1));
|
||||
EXPECT_EQ(17, fv1());
|
||||
EXPECT_EQ(17, fv2());
|
||||
@ -121,7 +122,7 @@ TEST(FunctionViewTest, MoveAssignmentIsCopy) {
|
||||
rtc::FunctionView<int()> fv2(f23);
|
||||
EXPECT_EQ(17, fv1());
|
||||
EXPECT_EQ(23, fv2());
|
||||
fv2 = std::move(fv1);
|
||||
fv2 = std::move(fv1); // NOLINT(performance-move-const-arg)
|
||||
EXPECT_EQ(17, fv1());
|
||||
EXPECT_EQ(17, fv2());
|
||||
}
|
||||
|
Reference in New Issue
Block a user