css parser: Small optimization

Avoid creating a GFile until it is needed.
This commit is contained in:
Matthias Clasen 2024-05-03 13:07:31 -04:00
parent e570eb4f86
commit ed3b73871f

View File

@ -85,10 +85,7 @@ gtk_css_parser_new (GtkCssTokenizer *tokenizer,
self->ref_count = 1;
self->tokenizer = gtk_css_tokenizer_ref (tokenizer);
if (file)
{
self->file = g_object_ref (file);
self->directory = g_file_get_parent (file);
}
self->file = g_object_ref (file);
self->error_func = error_func;
self->user_data = user_data;
@ -207,7 +204,12 @@ gtk_css_parser_resolve_url (GtkCssParser *self,
}
if (self->directory == NULL)
return NULL;
{
if (self->file)
self->directory = g_file_get_parent (self->file);
if (self->directory == NULL)
return NULL;
}
return g_file_resolve_relative_path (self->directory, url);
}