From 4fb3d2bcca968e8a0f29d8a20f67238f64f40102 Mon Sep 17 00:00:00 2001 From: kwiberg Date: Fri, 22 Apr 2016 04:59:31 -0700 Subject: [PATCH] Add defaulted move constructors for some types that just got copy constructors They can all benefit from moving, since they contain std::string and std::vector. We intended to add these in https://codereview.webrtc.org/1896953004/, but got compiler errors we couldn't make sense of, so we skipped them. It turns out that what the compiler was complaining about was that when we said we'd have a user-defined move constructor, it stopped generating a copy assignment operator for us. This CL solves the problem by outfitting the types with defaulted copy and move assignment operators too. Review URL: https://codereview.webrtc.org/1899173002 Cr-Commit-Position: refs/heads/master@{#12469} --- webrtc/base/pathutils.cc | 4 ++++ webrtc/base/pathutils.h | 4 ++++ webrtc/modules/audio_coding/codecs/audio_encoder.cc | 7 +++++-- webrtc/modules/audio_coding/codecs/audio_encoder.h | 3 +++ webrtc/modules/desktop_capture/desktop_region.cc | 1 + webrtc/modules/desktop_capture/desktop_region.h | 1 + 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/webrtc/base/pathutils.cc b/webrtc/base/pathutils.cc index 60e2b8bf47..a420eb5136 100644 --- a/webrtc/base/pathutils.cc +++ b/webrtc/base/pathutils.cc @@ -56,6 +56,7 @@ Pathname::Pathname() } Pathname::Pathname(const Pathname&) = default; +Pathname::Pathname(Pathname&&) = default; Pathname::Pathname(const std::string& pathname) : folder_delimiter_(DEFAULT_FOLDER_DELIM) { @@ -67,6 +68,9 @@ Pathname::Pathname(const std::string& folder, const std::string& filename) SetPathname(folder, filename); } +Pathname& Pathname::operator=(const Pathname&) = default; +Pathname& Pathname::operator=(Pathname&&) = default; + void Pathname::SetFolderDelimiter(char delimiter) { ASSERT(IsFolderDelimiter(delimiter)); folder_delimiter_ = delimiter; diff --git a/webrtc/base/pathutils.h b/webrtc/base/pathutils.h index c155e8cd1d..2a0efa9763 100644 --- a/webrtc/base/pathutils.h +++ b/webrtc/base/pathutils.h @@ -45,9 +45,13 @@ public: Pathname(); Pathname(const Pathname&); + Pathname(Pathname&&); Pathname(const std::string& pathname); Pathname(const std::string& folder, const std::string& filename); + Pathname& operator=(const Pathname&); + Pathname& operator=(Pathname&&); + // Set's the default folder delimiter for this Pathname char folder_delimiter() const { return folder_delimiter_; } void SetFolderDelimiter(char delimiter); diff --git a/webrtc/modules/audio_coding/codecs/audio_encoder.cc b/webrtc/modules/audio_coding/codecs/audio_encoder.cc index f6bdd49f69..2b08dd8594 100644 --- a/webrtc/modules/audio_coding/codecs/audio_encoder.cc +++ b/webrtc/modules/audio_coding/codecs/audio_encoder.cc @@ -16,10 +16,13 @@ namespace webrtc { AudioEncoder::EncodedInfo::EncodedInfo() = default; - AudioEncoder::EncodedInfo::EncodedInfo(const EncodedInfo&) = default; - +AudioEncoder::EncodedInfo::EncodedInfo(EncodedInfo&&) = default; AudioEncoder::EncodedInfo::~EncodedInfo() = default; +AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=( + const EncodedInfo&) = default; +AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=(EncodedInfo&&) = + default; int AudioEncoder::RtpTimestampRateHz() const { return SampleRateHz(); diff --git a/webrtc/modules/audio_coding/codecs/audio_encoder.h b/webrtc/modules/audio_coding/codecs/audio_encoder.h index a9d96743f8..a0f1839e73 100644 --- a/webrtc/modules/audio_coding/codecs/audio_encoder.h +++ b/webrtc/modules/audio_coding/codecs/audio_encoder.h @@ -46,7 +46,10 @@ class AudioEncoder { struct EncodedInfo : public EncodedInfoLeaf { EncodedInfo(); EncodedInfo(const EncodedInfo&); + EncodedInfo(EncodedInfo&&); ~EncodedInfo(); + EncodedInfo& operator=(const EncodedInfo&); + EncodedInfo& operator=(EncodedInfo&&); std::vector redundant; }; diff --git a/webrtc/modules/desktop_capture/desktop_region.cc b/webrtc/modules/desktop_capture/desktop_region.cc index a4c4a5f91e..e130c10381 100644 --- a/webrtc/modules/desktop_capture/desktop_region.cc +++ b/webrtc/modules/desktop_capture/desktop_region.cc @@ -21,6 +21,7 @@ DesktopRegion::RowSpan::RowSpan(int32_t left, int32_t right) } DesktopRegion::Row::Row(const Row&) = default; +DesktopRegion::Row::Row(Row&&) = default; DesktopRegion::Row::Row(int32_t top, int32_t bottom) : top(top), bottom(bottom) { diff --git a/webrtc/modules/desktop_capture/desktop_region.h b/webrtc/modules/desktop_capture/desktop_region.h index d846917473..5278159412 100644 --- a/webrtc/modules/desktop_capture/desktop_region.h +++ b/webrtc/modules/desktop_capture/desktop_region.h @@ -48,6 +48,7 @@ class DesktopRegion { // have the same vertical position. struct Row { Row(const Row&); + Row(Row&&); Row(int32_t top, int32_t bottom); ~Row();