Commit a024c515 by wxf

修正警告: moving a local object in a return statement prevents copy elision

https://www.viva64.com/en/w/v828/

编译器会对返回本地变量优化([Named] Return Value Optimization (RVO/NRVO)),
无论是 C++11 之前还是之后, 添加 move 后反而会影响该优化.

C++ Core Guidelines F.48: Do not return std::move(local)
parent f903ffeb
...@@ -63,9 +63,9 @@ string HlsMakerImp::onOpenSegment(int index) { ...@@ -63,9 +63,9 @@ string HlsMakerImp::onOpenSegment(int index) {
WarnL << "create file failed," << segment_path << " " << get_uv_errmsg(); WarnL << "create file failed," << segment_path << " " << get_uv_errmsg();
} }
if (_params.empty()) { if (_params.empty()) {
return std::move(segment_name); return segment_name;
} }
return std::move(segment_name + "?" + _params); return segment_name + "?" + _params;
} }
void HlsMakerImp::onDelSegment(int index) { void HlsMakerImp::onDelSegment(int index) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论