Make fewer copies when using StringBuilder.

Replace calls to .str() which copies with .Release which moves in cases where that's safe.

This CL was generated by this command:
git grep -l 'StringBuilder' |
xargs perl -i -0 -pe "s/(rtc::StringBuilder (\S+);.*?return )\\g2.str\(\)/\$1\$2.Release\(\)/sg"

Bug: webrtc:8982
Change-Id: If4dadbeb039df010aaaa9e58da81c1971a84fe8f
Reviewed-on: https://webrtc-review.googlesource.com/100307
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24790}
This commit is contained in:
Jonas Olsson 2018-09-14 16:59:32 +02:00 committed by Commit Bot
parent 4e5342f06a
commit 84df1c724e
46 changed files with 65 additions and 65 deletions

View file

@ -78,7 +78,7 @@ std::string Candidate::ToStringInternal(bool sensitive) const {
<< ":" << related_address_.ToString() << ":" << username_ << ":" << ":" << related_address_.ToString() << ":" << username_ << ":"
<< password_ << ":" << network_id_ << ":" << network_cost_ << ":" << password_ << ":" << network_id_ << ":" << network_cost_ << ":"
<< generation_ << "]"; << generation_ << "]";
return ost.str(); return ost.Release();
} }
uint32_t Candidate::GetPriority(uint32_t type_preference, uint32_t Candidate::GetPriority(uint32_t type_preference,

View file

@ -36,7 +36,7 @@ std::string VideoCodecTestStats::FrameStatistics::ToString() const {
ss << " decode_time_us " << decode_time_us; ss << " decode_time_us " << decode_time_us;
ss << " rtp_timestamp " << rtp_timestamp; ss << " rtp_timestamp " << rtp_timestamp;
ss << " target_bitrate_kbps " << target_bitrate_kbps; ss << " target_bitrate_kbps " << target_bitrate_kbps;
return ss.str(); return ss.Release();
} }
VideoCodecTestStats::VideoStatistics::VideoStatistics() = default; VideoCodecTestStats::VideoStatistics::VideoStatistics() = default;
@ -83,7 +83,7 @@ std::string VideoCodecTestStats::VideoStatistics::ToString(
ss << "\n" << prefix << "num_key_frames: " << num_key_frames; ss << "\n" << prefix << "num_key_frames: " << num_key_frames;
ss << "\n" << prefix << "num_spatial_resizes: " << num_spatial_resizes; ss << "\n" << prefix << "num_spatial_resizes: " << num_spatial_resizes;
ss << "\n" << prefix << "max_nalu_size_bytes: " << max_nalu_size_bytes; ss << "\n" << prefix << "max_nalu_size_bytes: " << max_nalu_size_bytes;
return ss.str(); return ss.Release();
} }
VideoCodecTestStats::FrameStatistics::FrameStatistics(size_t frame_number, VideoCodecTestStats::FrameStatistics::FrameStatistics(size_t frame_number,

View file

@ -88,7 +88,7 @@ static std::string VectorToString(const std::vector<T>& vals) {
ost << vals[i].ToString(); ost << vals[i].ToString();
} }
ost << "]"; ost << "]";
return ost.str(); return ost.Release();
} }
// Options that can be applied to a VideoMediaChannel or a VideoMediaEngine. // Options that can be applied to a VideoMediaChannel or a VideoMediaEngine.
@ -120,7 +120,7 @@ struct VideoOptions {
screencast_min_bitrate_kbps); screencast_min_bitrate_kbps);
ost << ToStringIfSet("is_screencast ", is_screencast); ost << ToStringIfSet("is_screencast ", is_screencast);
ost << "}"; ost << "}";
return ost.str(); return ost.Release();
} }
// Enable denoising? This flag comes from the getUserMedia // Enable denoising? This flag comes from the getUserMedia
@ -157,7 +157,7 @@ struct RtpHeaderExtension {
ost << "uri: " << uri; ost << "uri: " << uri;
ost << ", id: " << id; ost << ", id: " << id;
ost << "}"; ost << "}";
return ost.str(); return ost.Release();
} }
std::string uri; std::string uri;
@ -626,7 +626,7 @@ struct RtpParameters {
separator = ", "; separator = ", ";
} }
ost << "}"; ost << "}";
return ost.str(); return ost.Release();
} }
protected: protected:

View file

@ -190,7 +190,7 @@ static std::string CodecVectorToString(const std::vector<VideoCodec>& codecs) {
} }
} }
out << "}"; out << "}";
return out.str(); return out.Release();
} }
static bool ValidateCodecFormats(const std::vector<VideoCodec>& codecs) { static bool ValidateCodecFormats(const std::vector<VideoCodec>& codecs) {
@ -962,7 +962,7 @@ std::string WebRtcVideoChannel::CodecSettingsVectorToString(
} }
} }
out << "}"; out << "}";
return out.str(); return out.Release();
} }
bool WebRtcVideoChannel::GetSendCodec(VideoCodec* codec) { bool WebRtcVideoChannel::GetSendCodec(VideoCodec* codec) {

View file

@ -106,7 +106,7 @@ std::string ToString(const AudioCodec& codec) {
ss << " }"; ss << " }";
} }
ss << " (" << codec.id << ")"; ss << " (" << codec.id << ")";
return ss.str(); return ss.Release();
} }
bool IsCodec(const AudioCodec& codec, const char* ref_name) { bool IsCodec(const AudioCodec& codec, const char* ref_name) {

View file

@ -28,7 +28,7 @@ std::string NetEqInput::PacketData::ToString() const {
<< "ts: " << header.timestamp << ", " << "ts: " << header.timestamp << ", "
<< "ssrc: " << header.ssrc << "}, " << "ssrc: " << header.ssrc << "}, "
<< "payload bytes: " << payload.size() << "}"; << "payload bytes: " << payload.size() << "}";
return ss.str(); return ss.Release();
} }
TimeLimitedNetEqInput::TimeLimitedNetEqInput(std::unique_ptr<NetEqInput> input, TimeLimitedNetEqInput::TimeLimitedNetEqInput(std::unique_ptr<NetEqInput> input,

View file

@ -54,7 +54,7 @@ std::string ProduceDebugText(int sample_rate_hz,
ss << "Sample rate: " << sample_rate_hz << " "; ss << "Sample rate: " << sample_rate_hz << " ";
ss << "Number of channels: " << number_of_channels << " "; ss << "Number of channels: " << number_of_channels << " ";
ss << "Number of sources: " << number_of_sources; ss << "Number of sources: " << number_of_sources;
return ss.str(); return ss.Release();
} }
AudioFrame frame_for_mixing; AudioFrame frame_for_mixing;

View file

@ -78,7 +78,7 @@ class FilePlayingSource : public AudioMixer::Source {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "{rate: " << sample_rate_hz_ << ", channels: " << number_of_channels_ ss << "{rate: " << sample_rate_hz_ << ", channels: " << number_of_channels_
<< ", samples_tot: " << wav_reader_->num_samples() << "}"; << ", samples_tot: " << wav_reader_->num_samples() << "}";
return ss.str(); return ss.Release();
} }
private: private:

View file

@ -38,7 +38,7 @@ std::string ProduceDebugText(int sample_rate_hz,
ss << "Sample rate: " << sample_rate_hz << " ,"; ss << "Sample rate: " << sample_rate_hz << " ,";
ss << "number of channels: " << number_of_channels << " ,"; ss << "number of channels: " << number_of_channels << " ,";
ss << "number of sources: " << number_of_sources; ss << "number of sources: " << number_of_sources;
return ss.str(); return ss.Release();
} }
std::string ProduceDebugText(const FrameCombinerConfig& config) { std::string ProduceDebugText(const FrameCombinerConfig& config) {
@ -47,7 +47,7 @@ std::string ProduceDebugText(const FrameCombinerConfig& config) {
ss << "number of channels: " << config.number_of_channels << " ,"; ss << "number of channels: " << config.number_of_channels << " ,";
ss << "limiter active: " << (config.use_limiter ? "on" : "off") << " ,"; ss << "limiter active: " << (config.use_limiter ? "on" : "off") << " ,";
ss << "wave frequency: " << config.wave_frequency << " ,"; ss << "wave frequency: " << config.wave_frequency << " ,";
return ss.str(); return ss.Release();
} }
AudioFrame frame1; AudioFrame frame1;

View file

@ -43,7 +43,7 @@ namespace {
std::string ProduceDebugText(size_t delay) { std::string ProduceDebugText(size_t delay) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << ", Delay: " << delay; ss << ", Delay: " << delay;
return ss.str(); return ss.Release();
} }
} // namespace } // namespace

View file

@ -161,7 +161,7 @@ void RunWronglyInsertOrderTest(int sample_rate_hz,
std::string ProduceDebugText(int sample_rate_hz) { std::string ProduceDebugText(int sample_rate_hz) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Sample rate: " << sample_rate_hz; ss << "Sample rate: " << sample_rate_hz;
return ss.str(); return ss.Release();
} }
} // namespace } // namespace

View file

@ -95,7 +95,7 @@ void RunCaptureNumBandsVerificationTest(int sample_rate_hz) {
std::string ProduceDebugText(int sample_rate_hz) { std::string ProduceDebugText(int sample_rate_hz) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Sample rate: " << sample_rate_hz; ss << "Sample rate: " << sample_rate_hz;
return ss.str(); return ss.Release();
} }
} // namespace } // namespace

View file

@ -28,7 +28,7 @@ namespace {
std::string ProduceDebugText(int sample_rate_hz) { std::string ProduceDebugText(int sample_rate_hz) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Sample rate: " << sample_rate_hz; ss << "Sample rate: " << sample_rate_hz;
return ss.str(); return ss.Release();
} }
constexpr size_t kDownSamplingFactors[] = {2, 4, 8}; constexpr size_t kDownSamplingFactors[] = {2, 4, 8};

View file

@ -606,13 +606,13 @@ class EchoCanceller3Tester {
std::string ProduceDebugText(int sample_rate_hz) { std::string ProduceDebugText(int sample_rate_hz) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Sample rate: " << sample_rate_hz; ss << "Sample rate: " << sample_rate_hz;
return ss.str(); return ss.Release();
} }
std::string ProduceDebugText(int sample_rate_hz, int variant) { std::string ProduceDebugText(int sample_rate_hz, int variant) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Sample rate: " << sample_rate_hz << ", variant: " << variant; ss << "Sample rate: " << sample_rate_hz << ", variant: " << variant;
return ss.str(); return ss.Release();
} }
} // namespace } // namespace

View file

@ -29,7 +29,7 @@ std::string ProduceDebugText(size_t delay, size_t down_sampling_factor) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Delay: " << delay; ss << "Delay: " << delay;
ss << ", Down sampling factor: " << down_sampling_factor; ss << ", Down sampling factor: " << down_sampling_factor;
return ss.str(); return ss.Release();
} }
} // namespace } // namespace

View file

@ -30,13 +30,13 @@ namespace {
std::string ProduceDebugText(int sample_rate_hz) { std::string ProduceDebugText(int sample_rate_hz) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Sample rate: " << sample_rate_hz; ss << "Sample rate: " << sample_rate_hz;
return ss.str(); return ss.Release();
} }
std::string ProduceDebugText(int sample_rate_hz, int delay) { std::string ProduceDebugText(int sample_rate_hz, int delay) {
rtc::StringBuilder ss(ProduceDebugText(sample_rate_hz)); rtc::StringBuilder ss(ProduceDebugText(sample_rate_hz));
ss << ", Delay: " << delay; ss << ", Delay: " << delay;
return ss.str(); return ss.Release();
} }
} // namespace } // namespace

View file

@ -230,7 +230,7 @@ void RunWrongExtractOrderTest(int sample_rate_hz,
std::string ProduceDebugText(int sample_rate_hz) { std::string ProduceDebugText(int sample_rate_hz) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Sample rate: " << sample_rate_hz; ss << "Sample rate: " << sample_rate_hz;
return ss.str(); return ss.Release();
} }
} // namespace } // namespace

View file

@ -177,14 +177,14 @@ void RunFilterUpdateTest(int num_blocks_to_process,
std::string ProduceDebugText(int filter_length_blocks) { std::string ProduceDebugText(int filter_length_blocks) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Length: " << filter_length_blocks; ss << "Length: " << filter_length_blocks;
return ss.str(); return ss.Release();
} }
std::string ProduceDebugText(size_t delay, int filter_length_blocks) { std::string ProduceDebugText(size_t delay, int filter_length_blocks) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Delay: " << delay << ", "; ss << "Delay: " << delay << ", ";
ss << ProduceDebugText(filter_length_blocks); ss << ProduceDebugText(filter_length_blocks);
return ss.str(); return ss.Release();
} }
} // namespace } // namespace

View file

@ -37,7 +37,7 @@ std::string ProduceDebugText(size_t delay, size_t down_sampling_factor) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Delay: " << delay; ss << "Delay: " << delay;
ss << ", Down sampling factor: " << down_sampling_factor; ss << ", Down sampling factor: " << down_sampling_factor;
return ss.str(); return ss.Release();
} }
constexpr size_t kNumMatchedFilters = 10; constexpr size_t kNumMatchedFilters = 10;

View file

@ -27,7 +27,7 @@ namespace {
std::string ProduceDebugText(int sample_rate_hz) { std::string ProduceDebugText(int sample_rate_hz) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Sample rate: " << sample_rate_hz; ss << "Sample rate: " << sample_rate_hz;
return ss.str(); return ss.Release();
} }
} // namespace } // namespace

View file

@ -31,13 +31,13 @@ namespace {
std::string ProduceDebugText(int sample_rate_hz) { std::string ProduceDebugText(int sample_rate_hz) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Sample rate: " << sample_rate_hz; ss << "Sample rate: " << sample_rate_hz;
return ss.str(); return ss.Release();
} }
std::string ProduceDebugText(int sample_rate_hz, size_t delay) { std::string ProduceDebugText(int sample_rate_hz, size_t delay) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << ProduceDebugText(sample_rate_hz) << ", Delay: " << delay; ss << ProduceDebugText(sample_rate_hz) << ", Delay: " << delay;
return ss.str(); return ss.Release();
} }
constexpr size_t kDownSamplingFactors[] = {2, 4, 8}; constexpr size_t kDownSamplingFactors[] = {2, 4, 8};

View file

@ -118,14 +118,14 @@ void RunFilterUpdateTest(int num_blocks_to_process,
std::string ProduceDebugText(int filter_length_blocks) { std::string ProduceDebugText(int filter_length_blocks) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Length: " << filter_length_blocks; ss << "Length: " << filter_length_blocks;
return ss.str(); return ss.Release();
} }
std::string ProduceDebugText(size_t delay, int filter_length_blocks) { std::string ProduceDebugText(size_t delay, int filter_length_blocks) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Delay: " << delay << ", "; ss << "Delay: " << delay << ", ";
ss << ProduceDebugText(filter_length_blocks); ss << ProduceDebugText(filter_length_blocks);
return ss.str(); return ss.Release();
} }
} // namespace } // namespace

View file

@ -106,7 +106,7 @@ std::string ProduceDebugText(size_t delay, int filter_length_blocks) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Delay: " << delay << ", "; ss << "Delay: " << delay << ", ";
ss << "Length: " << filter_length_blocks; ss << "Length: " << filter_length_blocks;
return ss.str(); return ss.Release();
} }
} // namespace } // namespace

View file

@ -73,7 +73,7 @@ std::string GainController2::ToString(
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "{enabled: " << (config.enabled ? "true" : "false") << ", " ss << "{enabled: " << (config.enabled ? "true" : "false") << ", "
<< "fixed_gain_dB: " << config.fixed_gain_db << "}"; << "fixed_gain_dB: " << config.fixed_gain_db << "}";
return ss.str(); return ss.Release();
} }
} // namespace webrtc } // namespace webrtc

View file

@ -644,7 +644,7 @@ std::string GetIndexedOutputWavFilename(const std::string& wav_name,
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << wav_name.substr(0, wav_name.size() - 4) << "_" << counter ss << wav_name.substr(0, wav_name.size() - 4) << "_" << counter
<< wav_name.substr(wav_name.size() - 4); << wav_name.substr(wav_name.size() - 4);
return ss.str(); return ss.Release();
} }
void WriteEchoLikelihoodGraphFileHeader(std::ofstream* output_file) { void WriteEchoLikelihoodGraphFileHeader(std::ofstream* output_file) {

View file

@ -100,13 +100,13 @@ void CheckSameSign(const ChannelBuffer<float>* src,
std::string FakeRecordingDeviceKindToString(int fake_rec_device_kind) { std::string FakeRecordingDeviceKindToString(int fake_rec_device_kind) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "fake recording device: " << fake_rec_device_kind; ss << "fake recording device: " << fake_rec_device_kind;
return ss.str(); return ss.Release();
} }
std::string AnalogLevelToString(int level) { std::string AnalogLevelToString(int level) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "analog level: " << level; ss << "analog level: " << level;
return ss.str(); return ss.Release();
} }
} // namespace } // namespace

View file

@ -131,7 +131,7 @@ class Stats {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << (GetMean() >= 0 ? GetMean() : -1) << ", " ss << (GetMean() >= 0 ? GetMean() : -1) << ", "
<< (GetStdDev() >= 0 ? GetStdDev() : -1); << (GetStdDev() >= 0 ? GetStdDev() : -1);
return ss.str(); return ss.Release();
} }
void Log(const std::string& units) { void Log(const std::string& units) {

View file

@ -29,7 +29,7 @@ namespace bwe {
static std::string ToString(uint32_t v) { static std::string ToString(uint32_t v) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << v; ss << v;
return ss.str(); return ss.Release();
} }
Logging::ThreadState::ThreadState() = default; Logging::ThreadState::ThreadState() = default;

View file

@ -279,7 +279,7 @@ std::string VideoCodecTestFixtureImpl::Config::ToString() const {
} }
} }
ss << "\n"; ss << "\n";
return ss.str(); return ss.Release();
} }
std::string VideoCodecTestFixtureImpl::Config::CodecName() const { std::string VideoCodecTestFixtureImpl::Config::CodecName() const {

View file

@ -186,7 +186,7 @@ class DtlsTransport : public DtlsTransportInternal {
rtc::StringBuilder sb; rtc::StringBuilder sb;
sb << "DtlsTransport[" << transport_name_ << "|" << component_ << "|" sb << "DtlsTransport[" << transport_name_ << "|" << component_ << "|"
<< RECEIVING_ABBREV[receiving()] << WRITABLE_ABBREV[writable()] << "]"; << RECEIVING_ABBREV[receiving()] << WRITABLE_ABBREV[writable()] << "]";
return sb.str(); return sb.Release();
} }
private: private:

View file

@ -177,7 +177,7 @@ class P2PTransportChannel : public IceTransportInternal {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Channel[" << transport_name_ << "|" << component_ << "|" ss << "Channel[" << transport_name_ << "|" << component_ << "|"
<< RECEIVING_ABBREV[receiving_] << WRITABLE_ABBREV[writable_] << "]"; << RECEIVING_ABBREV[receiving_] << WRITABLE_ABBREV[writable_] << "]";
return ss.str(); return ss.Release();
} }
private: private:

View file

@ -909,7 +909,7 @@ std::string Port::ToString() const {
ss << "Port[" << rtc::ToHex(reinterpret_cast<uintptr_t>(this)) << ":" ss << "Port[" << rtc::ToHex(reinterpret_cast<uintptr_t>(this)) << ":"
<< content_name_ << ":" << component_ << ":" << generation_ << ":" << type_ << content_name_ << ":" << component_ << ":" << generation_ << ":" << type_
<< ":" << network_->ToString() << "]"; << ":" << network_->ToString() << "]";
return ss.str(); return ss.Release();
} }
// TODO(honghaiz): Make the network cost configurable from user setting. // TODO(honghaiz): Make the network cost configurable from user setting.
@ -1612,7 +1612,7 @@ std::string Connection::ToString() const {
} else { } else {
ss << "-]"; ss << "-]";
} }
return ss.str(); return ss.Release();
} }
std::string Connection::ToSensitiveString() const { std::string Connection::ToSensitiveString() const {

View file

@ -1240,7 +1240,7 @@ std::string TurnPort::ReconstructedServerUrl() {
rtc::StringBuilder url; rtc::StringBuilder url;
url << scheme << ":" << server_address_.address.ipaddr().ToString() << ":" url << scheme << ":" << server_address_.address.ipaddr().ToString() << ":"
<< server_address_.address.port() << "?transport=" << transport; << server_address_.address.port() << "?transport=" << transport;
return url.str(); return url.Release();
} }
void TurnPort::TurnCustomizerMaybeModifyOutgoingStunMessage( void TurnPort::TurnCustomizerMaybeModifyOutgoingStunMessage(

View file

@ -600,7 +600,7 @@ std::string TurnServerConnection::ToString() const {
}; };
rtc::StringBuilder ost; rtc::StringBuilder ost;
ost << src_.ToString() << "-" << dst_.ToString() << ":"<< kProtos[proto_]; ost << src_.ToString() << "-" << dst_.ToString() << ":"<< kProtos[proto_];
return ost.str(); return ost.Release();
} }
TurnServerAllocation::TurnServerAllocation(TurnServer* server, TurnServerAllocation::TurnServerAllocation(TurnServer* server,
@ -633,7 +633,7 @@ TurnServerAllocation::~TurnServerAllocation() {
std::string TurnServerAllocation::ToString() const { std::string TurnServerAllocation::ToString() const {
rtc::StringBuilder ost; rtc::StringBuilder ost;
ost << "Alloc[" << conn_.ToString() << "]"; ost << "Alloc[" << conn_.ToString() << "]";
return ost.str(); return ost.Release();
} }
void TurnServerAllocation::HandleTurnMessage(const TurnMessage* msg) { void TurnServerAllocation::HandleTurnMessage(const TurnMessage* msg) {

View file

@ -3711,7 +3711,7 @@ void TestAudioCodecsAnswer(RtpTransceiverDirection offer_direction,
first = false; first = false;
} }
os << " }"; os << " }";
return os.str(); return os.Release();
}; };
EXPECT_TRUE(acd->codecs() == target_codecs) EXPECT_TRUE(acd->codecs() == target_codecs)

View file

@ -607,7 +607,7 @@ std::string GetSetDescriptionErrorMessage(cricket::ContentSource source,
rtc::StringBuilder oss; rtc::StringBuilder oss;
oss << "Failed to set " << (source == cricket::CS_LOCAL ? "local" : "remote") oss << "Failed to set " << (source == cricket::CS_LOCAL ? "local" : "remote")
<< " " << SdpTypeToString(type) << " sdp: " << error.message(); << " " << SdpTypeToString(type) << " sdp: " << error.message();
return oss.str(); return oss.Release();
} }
std::string GetStreamIdsString(rtc::ArrayView<const std::string> stream_ids) { std::string GetStreamIdsString(rtc::ArrayView<const std::string> stream_ids) {
@ -5847,7 +5847,7 @@ std::string PeerConnection::GetSessionErrorMsg() {
rtc::StringBuilder desc; rtc::StringBuilder desc;
desc << kSessionError << SessionErrorToString(session_error()) << ". "; desc << kSessionError << SessionErrorToString(session_error()) << ". ";
desc << kSessionErrorDesc << session_error_desc() << "."; desc << kSessionErrorDesc << session_error_desc() << ".";
return desc.str(); return desc.Release();
} }
void PeerConnection::ReportSdpFormatReceived( void PeerConnection::ReportSdpFormatReceived(

View file

@ -184,7 +184,7 @@ std::string MakeNetworkKey(const std::string& name,
int prefix_length) { int prefix_length) {
rtc::StringBuilder ost; rtc::StringBuilder ost;
ost << name << "%" << prefix.ToString() << "/" << prefix_length; ost << name << "%" << prefix.ToString() << "/" << prefix_length;
return ost.str(); return ost.Release();
} }
// Test if the network name matches the type<number> pattern, e.g. eth0. The // Test if the network name matches the type<number> pattern, e.g. eth0. The
// matching is case-sensitive. // matching is case-sensitive.
@ -1075,7 +1075,7 @@ std::string Network::ToString() const {
ss << "/" << AdapterTypeToString(underlying_type_for_vpn_); ss << "/" << AdapterTypeToString(underlying_type_for_vpn_);
} }
ss << ":id=" << id_ << "]"; ss << ":id=" << id_ << "]";
return ss.str(); return ss.Release();
} }
} // namespace rtc } // namespace rtc

View file

@ -136,7 +136,7 @@ std::string SSLIdentity::DerToPem(const std::string& pem_type,
result << "-----END " << pem_type << "-----\n"; result << "-----END " << pem_type << "-----\n";
return result.str(); return result.Release();
} }
// static // static

View file

@ -157,8 +157,8 @@ class StringBuilder {
size_t size() const { return str_.size(); } size_t size() const { return str_.size(); }
std::string Release() { std::string Release() {
std::string ret; std::string ret = std::move(str_);
std::swap(str_, ret); str_.clear();
return ret; return ret;
} }

View file

@ -145,7 +145,7 @@ class IntervalRange {
std::string ToString() const { std::string ToString() const {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "[" << min_ << "," << max_ << "]"; ss << "[" << min_ << "," << max_ << "]";
return ss.str(); return ss.Release();
} }
bool operator==(const IntervalRange& o) const { bool operator==(const IntervalRange& o) const {

View file

@ -78,7 +78,7 @@ void SortPacketFeedbackVector(std::vector<PacketFeedback>* vec) {
std::string SsrcToString(uint32_t ssrc) { std::string SsrcToString(uint32_t ssrc) {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "SSRC " << ssrc; ss << "SSRC " << ssrc;
return ss.str(); return ss.Release();
} }
// Checks whether an SSRC is contained in the list of desired SSRCs. // Checks whether an SSRC is contained in the list of desired SSRCs.
@ -424,7 +424,7 @@ std::string GetCandidatePairLogDescriptionAsString(
<< remote_candidate_type << ":" << remote_candidate_type << ":"
<< GetAddressFamilyAsString(config.remote_address_family) << "@" << GetAddressFamilyAsString(config.remote_address_family) << "@"
<< GetProtocolAsString(config.candidate_pair_protocol); << GetProtocolAsString(config.candidate_pair_protocol);
return ss.str(); return ss.Release();
} }
std::string GetDirectionAsString(PacketDirection direction) { std::string GetDirectionAsString(PacketDirection direction) {

View file

@ -164,7 +164,7 @@ std::string NetworkInformation::ToString() const {
ss << " " << address.ToString(); ss << " " << address.ToString();
} }
ss << "]"; ss << "]";
return ss.str(); return ss.Release();
} }
AndroidNetworkMonitor::AndroidNetworkMonitor( AndroidNetworkMonitor::AndroidNetworkMonitor(

View file

@ -218,7 +218,7 @@ TEST_F(StatsEndToEndTest, GetStats) {
std::string CompoundKey(const char* name, uint32_t ssrc) { std::string CompoundKey(const char* name, uint32_t ssrc) {
rtc::StringBuilder oss; rtc::StringBuilder oss;
oss << name << "_" << ssrc; oss << name << "_" << ssrc;
return oss.str(); return oss.Release();
} }
bool AllStatsFilled(const std::map<std::string, bool>& stats_map) { bool AllStatsFilled(const std::map<std::string, bool>& stats_map) {

View file

@ -36,7 +36,7 @@ std::string AggregatedStats::ToStringWithMultiplier(int multiplier) const {
ss << "min:" << (min * multiplier) << ", "; ss << "min:" << (min * multiplier) << ", ";
ss << "avg:" << (average * multiplier) << ", "; ss << "avg:" << (average * multiplier) << ", ";
ss << "max:" << (max * multiplier) << "}"; ss << "max:" << (max * multiplier) << "}";
return ss.str(); return ss.Release();
} }
// Class holding periodically computed metrics. // Class holding periodically computed metrics.

View file

@ -250,7 +250,7 @@ std::string VideoQualityTest::GenerateGraphTitle() const {
if (params_.ss[0].num_spatial_layers > 1) if (params_.ss[0].num_spatial_layers > 1)
ss << ", Layer #" << params_.ss[0].selected_sl; ss << ", Layer #" << params_.ss[0].selected_sl;
ss << ")"; ss << ")";
return ss.str(); return ss.Release();
} }
void VideoQualityTest::CheckParamsAndInjectionComponents() { void VideoQualityTest::CheckParamsAndInjectionComponents() {

View file

@ -1267,7 +1267,7 @@ std::string VideoStreamEncoder::AdaptCounter::ToString() const {
rtc::StringBuilder ss; rtc::StringBuilder ss;
ss << "Downgrade counts: fps: {" << ToString(fps_counters_); ss << "Downgrade counts: fps: {" << ToString(fps_counters_);
ss << "}, resolution: {" << ToString(resolution_counters_) << "}"; ss << "}, resolution: {" << ToString(resolution_counters_) << "}";
return ss.str(); return ss.Release();
} }
VideoStreamEncoderObserver::AdaptationSteps VideoStreamEncoderObserver::AdaptationSteps
@ -1361,7 +1361,7 @@ std::string VideoStreamEncoder::AdaptCounter::ToString(
for (size_t reason = 0; reason < kScaleReasonSize; ++reason) { for (size_t reason = 0; reason < kScaleReasonSize; ++reason) {
ss << (reason ? " cpu" : "quality") << ":" << counters[reason]; ss << (reason ? " cpu" : "quality") << ":" << counters[reason];
} }
return ss.str(); return ss.Release();
} }
} // namespace webrtc } // namespace webrtc