Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.0
sddm
0003-UserModel-optimize-filtering-out-duplicate...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0003-UserModel-optimize-filtering-out-duplicate-users-995.patch of Package sddm
From 47f28bb0b903ae1603b8f855e77bbeb79d8e6ace Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov <dmitry.torokhov@gmail.com> Date: Mon, 19 Mar 2018 19:07:12 -0700 Subject: [PATCH 3/6] UserModel: optimize filtering out duplicate users (#995) Instead of using naive approach of trying to detect duplicates when inserting a new user into the list of users, which is O(n^2) complexity, let's filter them out after the fact, which is much more efficient on real-world data. With this change time to load user list in our environment (over 500000 account entries) is reduced from over 1 hour to about 2 seconds. --- src/greeter/UserModel.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/greeter/UserModel.cpp b/src/greeter/UserModel.cpp index fae5cfa..daf93c5 100644 --- a/src/greeter/UserModel.cpp +++ b/src/greeter/UserModel.cpp @@ -75,13 +75,6 @@ namespace SDDM { if (mainConfig.Users.HideShells.get().contains(QString::fromLocal8Bit(current_pw->pw_shell))) continue; - // skip duplicates - // Note: getpwent() makes no attempt to suppress duplicate information - // if multiple sources are specified in nsswitch.conf(5). - if (d->users.cend() - != std::find_if(d->users.cbegin(), d->users.cend(), [current_pw](const UserPtr & u) { return u->uid == current_pw->pw_uid; })) - continue; - // create user UserPtr user { new User() }; user->name = QString::fromLocal8Bit(current_pw->pw_name); @@ -107,6 +100,9 @@ namespace SDDM { // sort users by username std::sort(d->users.begin(), d->users.end(), [&](const UserPtr &u1, const UserPtr &u2) { return u1->name < u2->name; }); + // Remove duplicates in case we have several sources specified + // in nsswitch.conf(5). + std::unique(d->users.begin(), d->users.end(), [&](const UserPtr &u1, const UserPtr &u2) { return u1->name == u2->name; }); bool avatarsEnabled = mainConfig.Theme.EnableAvatars.get(); if (avatarsEnabled && mainConfig.Theme.EnableAvatars.isDefault()) { -- 2.16.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor