From aff3732314c80ddfd02380c8d7a6bd9fce600601 Mon Sep 17 00:00:00 2001 From: lainsce Date: Thu, 19 Jan 2023 23:38:55 -0300 Subject: [PATCH] simplify --- lib/Widgets/Avatar.vala | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/lib/Widgets/Avatar.vala b/lib/Widgets/Avatar.vala index 45e56db9..0b8fcb73 100644 --- a/lib/Widgets/Avatar.vala +++ b/lib/Widgets/Avatar.vala @@ -109,27 +109,18 @@ public class He.Avatar : He.Bin { } private string extract_initials (string t) { - string i = ""; - string p = t.up (-1); - string n = p._strip ().normalize (-1, GLib.NormalizeMode.DEFAULT_COMPOSE); - string u; - string q = ""; + string ret = ""; - if (n == null) + if (t.length == 0) return ""; - - u = n; - i += u; - - q = n.rchr (-1, ' '); - if (q != "") { - u = q; - - if (u != "") - i += u; - } - - return i; + + ret += t[0].to_string ().up (); + + for (int i = 1; i < t.length - 1; i++) + if (t[i] == ' ') + ret += t[i+1].to_string ().up (); + + return ret; }