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

Commit 46975eac authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "libprocessgroup: Make GetProfile() and GetAttribute() more efficient"...

Merge "libprocessgroup: Make GetProfile() and GetAttribute() more efficient" am: 56183d87 am: 42ae61e5 am: 5a787b52 am: e52cb6fc am: f38316a4

Original change: https://android-review.googlesource.com/c/platform/system/core/+/2174783



Change-Id: I81242ede836456238f8b1a2c1601ba8590ff2af4
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 72ac3885 f38316a4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -786,7 +786,7 @@ bool TaskProfiles::Load(const CgroupMap& cg_map, const std::string& file_name) {
    return true;
}

TaskProfile* TaskProfiles::GetProfile(const std::string& name) const {
TaskProfile* TaskProfiles::GetProfile(std::string_view name) const {
    auto iter = profiles_.find(name);

    if (iter != profiles_.end()) {
@@ -795,7 +795,7 @@ TaskProfile* TaskProfiles::GetProfile(const std::string& name) const {
    return nullptr;
}

const IProfileAttribute* TaskProfiles::GetAttribute(const std::string& name) const {
const IProfileAttribute* TaskProfiles::GetAttribute(std::string_view name) const {
    auto iter = attributes_.find(name);

    if (iter != attributes_.end()) {
+6 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <map>
#include <mutex>
#include <string>
#include <string_view>
#include <vector>

#include <android-base/unique_fd.h>
@@ -206,18 +207,18 @@ class TaskProfiles {
    // Should be used by all users
    static TaskProfiles& GetInstance();

    TaskProfile* GetProfile(const std::string& name) const;
    const IProfileAttribute* GetAttribute(const std::string& name) const;
    TaskProfile* GetProfile(std::string_view name) const;
    const IProfileAttribute* GetAttribute(std::string_view name) const;
    void DropResourceCaching(ProfileAction::ResourceCacheType cache_type) const;
    bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& profiles,
                            bool use_fd_cache);
    bool SetTaskProfiles(int tid, const std::vector<std::string>& profiles, bool use_fd_cache);

  private:
    std::map<std::string, std::shared_ptr<TaskProfile>> profiles_;
    std::map<std::string, std::unique_ptr<IProfileAttribute>> attributes_;

    TaskProfiles();

    bool Load(const CgroupMap& cg_map, const std::string& file_name);

    std::map<std::string, std::shared_ptr<TaskProfile>, std::less<>> profiles_;
    std::map<std::string, std::unique_ptr<IProfileAttribute>, std::less<>> attributes_;
};