diff options
author | 2024-02-12 22:50:58 -0500 | |
---|---|---|
committer | 2024-02-12 23:04:59 -0500 | |
commit | 652182c4d30d4897138c288f8044432c502567c5 (patch) | |
tree | edcc2b9cf41f169444c28ca479a3503e57d510fd | |
parent | 7fd8fcb360a430138aa34a8b38b0a99039462ff1 (diff) |
No need to std::move local variable to return value
- when no std::move is used, local variable that is returned is directly
constructed in the address of the return value
- when std::move is used, the return value has to be move constructed
from the rvalue of std::move, resulting in one more ctor call, not to
mention the added code complexity
- See Return Value Optimization in Effective Modern C++ by Scott Meyer,
Item 25
- also delete unrelated outdated comment
Test: compiles and runs
Change-Id: I1b71ea01c6ab1788432e846d9feeb2df608e6b6d
Signed-off-by: Daniel Zhang <danielzhang130@gmail.com>
-rw-r--r-- | libs/androidfw/Asset.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/libs/androidfw/Asset.cpp b/libs/androidfw/Asset.cpp index 43a70c176a83..5a4cff0c319e 100644 --- a/libs/androidfw/Asset.cpp +++ b/libs/androidfw/Asset.cpp @@ -309,9 +309,8 @@ Asset::Asset(void) return NULL; } - // We succeeded, so relinquish control of dataMap pAsset->mAccessMode = mode; - return std::move(pAsset); + return pAsset; } /* @@ -328,9 +327,8 @@ Asset::Asset(void) return NULL; } - // We succeeded, so relinquish control of dataMap pAsset->mAccessMode = mode; - return std::move(pAsset); + return pAsset; } /* |