From 2a8231063ca50aaa72cb6ea11cb19af067112ea1 Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Mon, 13 Nov 2017 11:50:33 +0100 Subject: [PATCH] Avoiding unnecessary copies. clang-tidy spotted out these unnecessary copies, this CL removes them. Bug: None Change-Id: I9035a5a5394e170e8193966b4790946fb22b3b76 No-Try: True Reviewed-on: https://webrtc-review.googlesource.com/22060 Commit-Queue: Mirko Bonadei Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#20648} --- pc/peerconnectionwrapper.cc | 13 ++++++++----- pc/peerconnectionwrapper.h | 5 +++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pc/peerconnectionwrapper.cc b/pc/peerconnectionwrapper.cc index ddfa5a6907..14308b5789 100644 --- a/pc/peerconnectionwrapper.cc +++ b/pc/peerconnectionwrapper.cc @@ -18,6 +18,7 @@ #include "api/jsepsessiondescription.h" #include "media/base/fakevideocapturer.h" #include "pc/sdputils.h" +#include "rtc_base/function_view.h" #include "rtc_base/gunit.h" #include "rtc_base/ptr_util.h" @@ -31,7 +32,9 @@ PeerConnectionWrapper::PeerConnectionWrapper( rtc::scoped_refptr pc_factory, rtc::scoped_refptr pc, std::unique_ptr observer) - : pc_factory_(pc_factory), observer_(std::move(observer)), pc_(pc) { + : pc_factory_(std::move(pc_factory)), + observer_(std::move(observer)), + pc_(std::move(pc)) { RTC_DCHECK(pc_factory_); RTC_DCHECK(pc_); RTC_DCHECK(observer_); @@ -118,7 +121,7 @@ PeerConnectionWrapper::CreateAnswerAndSetAsLocal( } std::unique_ptr PeerConnectionWrapper::CreateSdp( - std::function fn, + rtc::FunctionView fn, std::string* error_out) { rtc::scoped_refptr observer( new rtc::RefCountedObject()); @@ -151,7 +154,7 @@ bool PeerConnectionWrapper::SetRemoteDescription( } bool PeerConnectionWrapper::SetSdp( - std::function fn, + rtc::FunctionView fn, std::string* error_out) { rtc::scoped_refptr observer( new rtc::RefCountedObject()); @@ -168,7 +171,7 @@ rtc::scoped_refptr PeerConnectionWrapper::AddAudioTrack( std::vector streams) { auto media_stream_track = pc_factory()->CreateAudioTrack(track_label, nullptr); - return pc()->AddTrack(media_stream_track, streams); + return pc()->AddTrack(media_stream_track, std::move(streams)); } rtc::scoped_refptr PeerConnectionWrapper::AddVideoTrack( @@ -178,7 +181,7 @@ rtc::scoped_refptr PeerConnectionWrapper::AddVideoTrack( rtc::MakeUnique()); auto media_stream_track = pc_factory()->CreateVideoTrack(track_label, video_source); - return pc()->AddTrack(media_stream_track, streams); + return pc()->AddTrack(media_stream_track, std::move(streams)); } PeerConnectionInterface::SignalingState diff --git a/pc/peerconnectionwrapper.h b/pc/peerconnectionwrapper.h index 2554f1f499..ca805a3c13 100644 --- a/pc/peerconnectionwrapper.h +++ b/pc/peerconnectionwrapper.h @@ -18,6 +18,7 @@ #include "api/peerconnectioninterface.h" #include "pc/test/mockpeerconnectionobservers.h" +#include "rtc_base/function_view.h" namespace webrtc { @@ -117,9 +118,9 @@ class PeerConnectionWrapper { private: std::unique_ptr CreateSdp( - std::function fn, + rtc::FunctionView fn, std::string* error_out); - bool SetSdp(std::function fn, + bool SetSdp(rtc::FunctionView fn, std::string* error_out); rtc::scoped_refptr pc_factory_;