From 1f17fb940c285979da3f655e9bf18344b78fa45c Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 10 Nov 2013 17:41:08 +0100 Subject: [PATCH] wmaker: Avoid multiple calls to gettext The original code called gettext twice every time, the new code calls it only once. Signed-off-by: Christophe CURIS --- src/workspace.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/workspace.c b/src/workspace.c index 4e619efd..1365cc95 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -94,8 +94,15 @@ int wWorkspaceNew(WScreen *scr) wspace->clip = NULL; if (!wspace->name) { - wspace->name = wmalloc(strlen(_("Workspace %i")) + 8); - sprintf(wspace->name, _("Workspace %i"), w_global.workspace.count); + static const char *new_name = NULL; + static size_t name_length; + + if (new_name == NULL) { + new_name = _("Workspace %i"); + name_length = strlen(new_name) + 8; + } + wspace->name = wmalloc(name_length); + snprintf(wspace->name, name_length, new_name, w_global.workspace.count); } if (!wPreferences.flags.noclip)