Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ebea9097 authored by Bart Van Assche's avatar Bart Van Assche
Browse files

Micro-optimize MergeCgroupToDescriptors()



Introduce a local variable for an expression that occurs twice. Use
string append instead of string concatenation because the former is more
efficient.

Bug: 213617178
Test: Compile-tested only.
Change-Id: I6e8b9d63b10accb220216dc484dffd18f5c54ce7
Signed-off-by: default avatarBart Van Assche <bvanassche@google.com>
parent 9b5a2320
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -147,12 +147,15 @@ static bool Mkdir(const std::string& path, mode_t mode, const std::string& uid,
static void MergeCgroupToDescriptors(std::map<std::string, CgroupDescriptor>* descriptors,
                                     const Json::Value& cgroup, const std::string& name,
                                     const std::string& root_path, int cgroups_version) {
    const std::string cgroup_path = cgroup["Path"].asString();
    std::string path;

    if (!root_path.empty()) {
        path = root_path + "/" + cgroup["Path"].asString();
        path = root_path;
        path += "/";
        path += cgroup_path;
    } else {
        path = cgroup["Path"].asString();
        path = cgroup_path;
    }

    uint32_t controller_flags = 0;