[gnome-system-monitor] Move the UserMap directly into ProcInfo::lookup_user(...). Less code for the same thing.



commit 99b6bdec7124823a43b1e058ac75848fcd1f55d5
Author: Benoît Dejean <bdejean gmail com>
Date:   Sat Oct 15 14:44:42 2016 +0200

    Move the UserMap directly into ProcInfo::lookup_user(...).
    Less code for the same thing.

 src/application.h |    4 ----
 src/proctable.cpp |    6 ++----
 2 files changed, 2 insertions(+), 8 deletions(-)
---
diff --git a/src/application.h b/src/application.h
index 857fdce..68eff87 100644
--- a/src/application.h
+++ b/src/application.h
@@ -134,10 +134,6 @@ class ProcInfo
     /* undefined */ ProcInfo& operator=(const ProcInfo&);
     /* undefined */ ProcInfo(const ProcInfo&);
 
-    typedef std::map<guint, std::string> UserMap;
-    /* cached username */
-    static UserMap users;
-
   public:
 
     // TODO: use a set instead
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 82c4f82..be3fa69 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -63,7 +63,6 @@
 #include <gdk/gdkx.h>
 #endif
 
-ProcInfo::UserMap ProcInfo::users;
 ProcInfo::List ProcInfo::all;
 std::map<pid_t, guint64> ProcInfo::cpu_times;
 
@@ -651,9 +650,8 @@ get_process_name (ProcInfo *info,
 std::string
 ProcInfo::lookup_user(guint uid)
 {
-    typedef std::pair<ProcInfo::UserMap::iterator, bool> Pair;
-    ProcInfo::UserMap::value_type hint(uid, "");
-    Pair p(ProcInfo::users.insert(hint));
+    static std::map<guint, std::string> users;
+    auto p = users.insert({uid, ""});
 
     // procman_debug("User lookup for uid %u: %s", uid, (p.second ? "MISS" : "HIT"));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]