From: Holger Hans Peter Freyther <[email protected]>

The routine is dominated by the fgets and not the code that is
moved around. Doing the work only for the lines that will be
used should be a small gain. Routines in the selinux-access.c
should probably query the gid and uid at the same time instead
of opening and parsing the file twice.
---
 src/shared/util.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/shared/util.c b/src/shared/util.c
index ce8f866..d5ed615 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -746,11 +746,9 @@ static int get_process_id(pid_t pid, const char *field, 
uid_t *uid) {
                 return -errno;
 
         FOREACH_LINE(line, f, return -errno) {
-                char *l;
 
-                l = strstrip(line);
-
-                if (startswith(l, field)) {
+                if (startswith(line, field)) {
+                        char *l = strstrip(line);
                         l += strlen(field);
                         l += strspn(l, WHITESPACE);
 
-- 
1.7.10.4

_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to