================ @@ -0,0 +1,23 @@ +.. title:: clang-tidy - performance-move-smart-pointer-contents + +performance-move-smart-pointer-contents +======================================= + +Given a smart pointer containing a movable type, such as a +`std::unique_ptr<SomeProtocolBuffer>`, it's possible to move the contents of the +pointer rather than the pointer itself (ie `std::move(*p)` rather than +`*std::move(p)`). Doing so is a pessimization if the type cannot be efficiently +moved, as the pointer will be quicker than a larger type. + ---------------- HerrCai0907 wrote:
I think the performance issue will happened only when `SomeProtocolBuffer` is `is_trivially_move_constructible` and is a large type. You will not get any benefit from ```c++ std::unique_ptr<int> p; int x = std::move(*p); ``` to ```c++ std::unique_ptr<int> p; int x = *std::move(p); ``` https://github.com/llvm/llvm-project/pull/66139 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits