From 852f9ff329ff7c1a00aeaa468bc25e956ae0b81a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 26 Sep 2024 12:10:30 -0500 Subject: [PATCH] perf: build g_dgettext domain name at compile time (#43960) perf: build GettextPackage name at compile time --- shell/browser/ui/gtk_util.cc | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/shell/browser/ui/gtk_util.cc b/shell/browser/ui/gtk_util.cc index 651ab5059604..faa6b2985479 100644 --- a/shell/browser/ui/gtk_util.cc +++ b/shell/browser/ui/gtk_util.cc @@ -8,16 +8,12 @@ #include #include -#include -#include - -#include "base/no_destructor.h" -#include "base/strings/string_number_conversions.h" +#include "base/macros/remove_parens.h" +#include "base/strings/stringize_macros.h" #include "electron/electron_gtk_stubs.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkUnPreMultiply.h" -#include "ui/gtk/gtk_compat.h" // nogncheck // The following utilities are pulled from // https://source.chromium.org/chromium/chromium/src/+/main:ui/gtk/select_file_dialog_linux_gtk.cc;l=44-75;drc=a03ba4ca94f75531207c3ea832d6a605cde77394 @@ -25,14 +21,12 @@ namespace gtk_util { namespace { -const char* GettextPackage() { - static base::NoDestructor gettext_package( - "gtk" + base::NumberToString(gtk::GtkVersion().components()[0]) + "0"); - return gettext_package->c_str(); -} - const char* GtkGettext(const char* str) { - return g_dgettext(GettextPackage(), str); + // ex: "gtk30". GTK_MAJOR_VERSION is #defined as an int in parenthesis, + // like (3), so use base macros to remove parenthesis and stringize it + static const char kGettextDomain[] = + "gtk" STRINGIZE(BASE_REMOVE_PARENS(GTK_MAJOR_VERSION)) "0"; + return g_dgettext(kGettextDomain, str); } } // namespace