From eb91fe48fe8798647abd19f41ad9cfbd58403bc2 Mon Sep 17 00:00:00 2001 From: Ali Tofigh Date: Thu, 7 Jul 2022 15:16:23 +0200 Subject: [PATCH] Remove unnecessary std::string overloads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes std::string version of rtc::RtcEventLogOutput::Write() no longer pure virtual while making the absl::string_view version pure virtual. Also removes unnecessary overloads in subclasses. BUG=webrtc:13579 Change-Id: I8fb449560b795a1ef76fab27533d9042d0c34cd1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268062 Commit-Queue: Ali Tofigh Reviewed-by: Björn Terelius Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#37484} --- api/rtc_event_log_output.h | 10 +++++----- api/rtc_event_log_output_file.cc | 4 ---- api/rtc_event_log_output_file.h | 1 - pc/peer_connection_interface_unittest.cc | 1 - test/logging/file_log_writer.cc | 4 ---- test/logging/file_log_writer.h | 1 - test/logging/memory_log_writer.cc | 4 ---- 7 files changed, 5 insertions(+), 20 deletions(-) diff --git a/api/rtc_event_log_output.h b/api/rtc_event_log_output.h index 69951893c6..ae61de62d7 100644 --- a/api/rtc_event_log_output.h +++ b/api/rtc_event_log_output.h @@ -33,12 +33,12 @@ class RtcEventLogOutput { // about how much data was written, if any. The output sink becomes inactive // after the first time `false` is returned. Write() may not be called on // an inactive output sink. - virtual bool Write(const std::string& output) = 0; - // TODO(bugs.webrtc.org/13579): Make pure virtual and remove the string ref - // once all classes implement the string_view version. - virtual bool Write(absl::string_view output) { - return Write(std::string(output)); + virtual bool Write(const std::string& output) { + return Write(absl::string_view(output)); } + // TODO(bugs.webrtc.org/13579): Remove the string ref once all classes + // implement the string_view version. + virtual bool Write(absl::string_view output) = 0; // Indicates that buffers should be written to disk if applicable. virtual void Flush() {} diff --git a/api/rtc_event_log_output_file.cc b/api/rtc_event_log_output_file.cc index 2ba3e021ba..e1d4c7c711 100644 --- a/api/rtc_event_log_output_file.cc +++ b/api/rtc_event_log_output_file.cc @@ -54,10 +54,6 @@ bool RtcEventLogOutputFile::IsActive() const { return IsActiveInternal(); } -bool RtcEventLogOutputFile::Write(const std::string& output) { - return Write(absl::string_view(output)); -} - bool RtcEventLogOutputFile::Write(absl::string_view output) { RTC_DCHECK(IsActiveInternal()); // No single write may be so big, that it would risk overflowing the diff --git a/api/rtc_event_log_output_file.h b/api/rtc_event_log_output_file.h index 1f459bd3cd..c9ae0a8ede 100644 --- a/api/rtc_event_log_output_file.h +++ b/api/rtc_event_log_output_file.h @@ -37,7 +37,6 @@ class RtcEventLogOutputFile final : public RtcEventLogOutput { bool IsActive() const override; - bool Write(const std::string& output) override; bool Write(absl::string_view output) override; private: diff --git a/pc/peer_connection_interface_unittest.cc b/pc/peer_connection_interface_unittest.cc index 2991fac588..3cf876af9a 100644 --- a/pc/peer_connection_interface_unittest.cc +++ b/pc/peer_connection_interface_unittest.cc @@ -437,7 +437,6 @@ static const char kDtlsSdesFallbackSdp[] = class RtcEventLogOutputNull final : public RtcEventLogOutput { public: bool IsActive() const override { return true; } - bool Write(const std::string& /*output*/) override { return true; } bool Write(const absl::string_view /*output*/) override { return true; } }; diff --git a/test/logging/file_log_writer.cc b/test/logging/file_log_writer.cc index 106143a3fb..9598bc079c 100644 --- a/test/logging/file_log_writer.cc +++ b/test/logging/file_log_writer.cc @@ -32,10 +32,6 @@ bool FileLogWriter::IsActive() const { return true; } -bool FileLogWriter::Write(const std::string& value) { - return Write(absl::string_view(value)); -} - bool FileLogWriter::Write(absl::string_view value) { // We don't expect the write to fail. If it does, we don't want to risk // silently ignoring it. diff --git a/test/logging/file_log_writer.h b/test/logging/file_log_writer.h index b0dbf03b15..b1355d325a 100644 --- a/test/logging/file_log_writer.h +++ b/test/logging/file_log_writer.h @@ -24,7 +24,6 @@ class FileLogWriter final : public RtcEventLogOutput { explicit FileLogWriter(std::string file_path); ~FileLogWriter() final; bool IsActive() const override; - bool Write(const std::string& value) override; bool Write(absl::string_view value) override; void Flush() override; diff --git a/test/logging/memory_log_writer.cc b/test/logging/memory_log_writer.cc index 4a5e536059..9c5f32fe13 100644 --- a/test/logging/memory_log_writer.cc +++ b/test/logging/memory_log_writer.cc @@ -23,10 +23,6 @@ class MemoryLogWriter final : public RtcEventLogOutput { : target_(target), filename_(filename) {} ~MemoryLogWriter() final { target_->insert({filename_, std::move(buffer_)}); } bool IsActive() const override { return true; } - bool Write(const std::string& value) override { - buffer_.append(value); - return true; - } bool Write(absl::string_view value) override { buffer_.append(value.data(), value.size()); return true;