OSDN Git Service

Avoid extra string copy
authorGreg Kaiser <gkaiser@google.com>
Wed, 12 Feb 2020 15:11:09 +0000 (07:11 -0800)
committerGreg Kaiser <gkaiser@google.com>
Wed, 12 Feb 2020 15:11:09 +0000 (07:11 -0800)
We directly pass a reference to our std::string, instead of
forcing the creation of a temporary std::string from the
result of c_str().

Test: TreeHugger
Change-Id: Ibab13f1e1ff43af076df60ae4032bf9dd111dd27

Utils.cpp

index 6894c6c..b31008c 100644 (file)
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -293,7 +293,7 @@ int PrepareAppDirFromRoot(std::string path, int appUid) {
         // All dirs use the "app" project ID, except for the cache dir
         projectId = uid - AID_APP_START + AID_CACHE_GID_START;
     }
-    return PrepareDirWithProjectId(path.c_str(), mode, uid, gid, projectId);
+    return PrepareDirWithProjectId(path, mode, uid, gid, projectId);
 }
 
 status_t PrepareDir(const std::string& path, mode_t mode, uid_t uid, gid_t gid) {