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

Commit 8923d722 authored by Bart Van Assche's avatar Bart Van Assche
Browse files

Micro-optimize CgroupMap::ActivateControllers()



The C++ string concatenation operator is inefficient because it always
allocates a new string, even in cases where std::string::apppend() does
not allocate a new string. Hence this patch that replaces string
concatenation with a call to std::string::append().

Bug: 213617178
Test: Booted Android in Cuttlefish.
Change-Id: I79bdb89e957d3cfb40e48ef00c3e5576b4f533a5
Signed-off-by: default avatarBart Van Assche <bvanassche@google.com>
parent 20d59bd2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -231,7 +231,8 @@ int CgroupMap::ActivateControllers(const std::string& path) const {
            const ACgroupController* controller = ACgroupFile_getController(i);
            if (ACgroupController_getFlags(controller) &
                CGROUPRC_CONTROLLER_FLAG_NEEDS_ACTIVATION) {
                std::string str = std::string("+") + ACgroupController_getName(controller);
                std::string str("+");
                str.append(ACgroupController_getName(controller));
                if (!WriteStringToFile(str, path + "/cgroup.subtree_control")) {
                    return -errno;
                }