gresource: Avoid a gettext lookup on a hot error path

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4242#note_2215991

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3465
This commit is contained in:
Philip Withnall 2024-09-12 14:42:28 +01:00
parent b2d8394f17
commit 26f2d54840
No known key found for this signature in database
GPG Key ID: DCDF5885B1F3ED73

View File

@ -679,9 +679,11 @@ static void
set_error_not_found (GError **error,
const char *path)
{
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
_("The resource at “%s” does not exist"),
path);
/* Avoid looking up the translation if its not going to be used. This is a hot path. */
if (error != NULL)
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
_("The resource at “%s” does not exist"),
path);
}
/* The only error this can return is %G_RESOURCE_ERROR_NOT_FOUND. */