button: save a few cycles by returning early

...and in preparation for the merge-config patch, avoid building
directory lists for empty filenames.
This commit is contained in:
Johan Malm 2024-01-17 21:50:53 +00:00 committed by Johan Malm
parent 4238d7fc33
commit d0aff49c81
3 changed files with 9 additions and 0 deletions

View file

@ -49,6 +49,9 @@ button_png_load(const char *button_name, struct lab_data_buffer **buffer)
wlr_buffer_drop(&(*buffer)->base); wlr_buffer_drop(&(*buffer)->base);
*buffer = NULL; *buffer = NULL;
} }
if (!button_name || !*button_name) {
return;
}
char path[4096] = { 0 }; char path[4096] = { 0 };
button_filename(button_name, path, sizeof(path)); button_filename(button_name, path, sizeof(path));

View file

@ -22,6 +22,9 @@ button_svg_load(const char *button_name, struct lab_data_buffer **buffer,
wlr_buffer_drop(&(*buffer)->base); wlr_buffer_drop(&(*buffer)->base);
*buffer = NULL; *buffer = NULL;
} }
if (!button_name || !*button_name) {
return;
}
char filename[4096] = { 0 }; char filename[4096] = { 0 };
button_filename(button_name, filename, sizeof(filename)); button_filename(button_name, filename, sizeof(filename));

View file

@ -279,6 +279,9 @@ button_xbm_load(const char *button_name, struct lab_data_buffer **buffer,
wlr_buffer_drop(&(*buffer)->base); wlr_buffer_drop(&(*buffer)->base);
*buffer = NULL; *buffer = NULL;
} }
if (!button_name || !*button_name) {
return;
}
color = argb32(rgba); color = argb32(rgba);
/* Read file into memory as it's easier to tokenize that way */ /* Read file into memory as it's easier to tokenize that way */