Avoid string duplication when returning StringBuilder strings
The const-ref result of .str() must be copied into the returned value, whereas the result of .Release() can be moved. Bug: webrtc:374845009 Change-Id: I3abc98be30ce9947127c7664f5ffa6846b772ea2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/366480 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43288}
This commit is contained in:
parent
b7cac14fd4
commit
7085a884aa
@ -181,7 +181,7 @@ std::string SdpVideoFormat::ToString() const {
|
|||||||
builder << "]";
|
builder << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.str();
|
return builder.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SdpVideoFormat::IsSameCodec(const SdpVideoFormat& other) const {
|
bool SdpVideoFormat::IsSameCodec(const SdpVideoFormat& other) const {
|
||||||
|
|||||||
@ -90,6 +90,6 @@ std::string ForwardTsnChunk::ToString() const {
|
|||||||
for (const auto& skipped : skipped_streams()) {
|
for (const auto& skipped : skipped_streams()) {
|
||||||
sb << ", skip " << skipped.stream_id.value() << ":" << *skipped.ssn;
|
sb << ", skip " << skipped.stream_id.value() << ":" << *skipped.ssn;
|
||||||
}
|
}
|
||||||
return sb.str();
|
return sb.Release();
|
||||||
}
|
}
|
||||||
} // namespace dcsctp
|
} // namespace dcsctp
|
||||||
|
|||||||
@ -894,7 +894,7 @@ void Connection::PrintPingsSinceLastResponse(std::string* s, size_t max) {
|
|||||||
oss << rtc::hex_encode(ping.id) << " ";
|
oss << rtc::hex_encode(ping.id) << " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*s = oss.str();
|
*s = oss.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Connection::selected() const {
|
bool Connection::selected() const {
|
||||||
|
|||||||
@ -196,7 +196,7 @@ std::string SimulcastSdpSerializer::SerializeSimulcastDescription(
|
|||||||
<< simulcast.receive_layers();
|
<< simulcast.receive_layers();
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.str();
|
return sb.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1
|
// https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1
|
||||||
@ -305,7 +305,7 @@ std::string SimulcastSdpSerializer::SerializeRidDescription(
|
|||||||
propertyDelimiter = kDelimiterSemicolon;
|
propertyDelimiter = kDelimiterSemicolon;
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.str();
|
return builder.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://tools.ietf.org/html/draft-ietf-mmusic-rid-15#section-10
|
// https://tools.ietf.org/html/draft-ietf-mmusic-rid-15#section-10
|
||||||
|
|||||||
@ -804,7 +804,7 @@ static void GetDefaultDestination(const std::vector<Candidate>& candidates,
|
|||||||
|
|
||||||
// Gets "a=rtcp" line if found default RTCP candidate from `candidates`.
|
// Gets "a=rtcp" line if found default RTCP candidate from `candidates`.
|
||||||
static std::string GetRtcpLine(const std::vector<Candidate>& candidates) {
|
static std::string GetRtcpLine(const std::vector<Candidate>& candidates) {
|
||||||
std::string rtcp_line, rtcp_port, rtcp_ip, addr_type;
|
std::string rtcp_port, rtcp_ip, addr_type;
|
||||||
GetDefaultDestination(candidates, ICE_CANDIDATE_COMPONENT_RTCP, &rtcp_port,
|
GetDefaultDestination(candidates, ICE_CANDIDATE_COMPONENT_RTCP, &rtcp_port,
|
||||||
&rtcp_ip, &addr_type);
|
&rtcp_ip, &addr_type);
|
||||||
// Found default RTCP candidate.
|
// Found default RTCP candidate.
|
||||||
@ -819,8 +819,7 @@ static std::string GetRtcpLine(const std::vector<Candidate>& candidates) {
|
|||||||
InitAttrLine(kAttributeRtcp, &os);
|
InitAttrLine(kAttributeRtcp, &os);
|
||||||
os << kSdpDelimiterColon << rtcp_port << " " << kConnectionNettype << " "
|
os << kSdpDelimiterColon << rtcp_port << " " << kConnectionNettype << " "
|
||||||
<< addr_type << " " << rtcp_ip;
|
<< addr_type << " " << rtcp_ip;
|
||||||
rtcp_line = os.str();
|
return os.Release();
|
||||||
return rtcp_line;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get candidates according to the mline index from SessionDescriptionInterface.
|
// Get candidates according to the mline index from SessionDescriptionInterface.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user