修正警告: 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)
This commit is contained in:
wxf 2020-09-13 11:07:19 +08:00
parent f903ffeb4a
commit a024c51536
1 changed files with 2 additions and 2 deletions

View File

@ -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) {