File 0005-UserModel-optimize-setting-of-default-user-icon-999.patch of Package sddm
From 1ea5a0a85488e425c2d1ffcf3eafa8d8b0abe0b1 Mon Sep 17 00:00:00 2001
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Fri, 6 Apr 2018 19:56:14 -0700
Subject: [PATCH 5/6] UserModel: optimize setting of default user icon (#999)
Instead of checking for existence of theme-specific icon and re-creating
string literals every time we add a new user to the list, do it once.
It helps in large organizations with a lot of users.
---
src/greeter/UserModel.cpp | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/greeter/UserModel.cpp b/src/greeter/UserModel.cpp
index 57f236d..f6f4f95 100644
--- a/src/greeter/UserModel.cpp
+++ b/src/greeter/UserModel.cpp
@@ -56,6 +56,8 @@ namespace SDDM {
const QString currentTheme = mainConfig.Theme.Current.get();
const QString themeDefaultFace = QStringLiteral("%1/%2/faces/.face.icon").arg(themeDir).arg(currentTheme);
const QString defaultFace = QStringLiteral("%1/.face.icon").arg(facesDir);
+ const QString iconURI = QStringLiteral("file://%1").arg(
+ QFile::exists(themeDefaultFace) ? themeDefaultFace : defaultFace);
struct passwd *current_pw;
while ((current_pw = getpwent()) != nullptr) {
@@ -85,12 +87,7 @@ namespace SDDM {
// if shadow is used pw_passwd will be 'x' nevertheless, so this
// will always be true
user->needsPassword = strcmp(current_pw->pw_passwd, "") != 0;
-
- // search for face icon
- if (QFile::exists(themeDefaultFace))
- user->icon = QStringLiteral("file://%1").arg(themeDefaultFace);
- else
- user->icon = QStringLiteral("file://%1").arg(defaultFace);
+ user->icon = iconURI;
// add user
d->users << user;
--
2.16.2