Skip to content

Commit

Permalink
Remove unnecessary calls to strlen in al_set_new_window_title and in …
Browse files Browse the repository at this point in the history
…al_get_new_window_title.
  • Loading branch information
alemart authored and SiegeLord committed Jun 8, 2024
1 parent 3fba50f commit fadf95d
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,11 @@ ALLEGRO_EXTRA_DISPLAY_SETTINGS *_al_get_new_display_settings(void)
void al_set_new_window_title(const char *title)
{
thread_local_state *tls;
size_t size;

if ((tls = tls_get()) == NULL)
return;

size = strlen(title);

if (size > ALLEGRO_NEW_WINDOW_TITLE_MAX_SIZE) {
size = ALLEGRO_NEW_WINDOW_TITLE_MAX_SIZE;
}

_al_sane_strncpy(tls->new_window_title, title, size + 1);
_al_sane_strncpy(tls->new_window_title, title, sizeof(tls->new_window_title));
}


Expand All @@ -233,10 +226,9 @@ const char *al_get_new_window_title(void)
if ((tls = tls_get()) == NULL)
return al_get_app_name();

if (strlen(tls->new_window_title) < 1)
if (tls->new_window_title[0] == '\0')
return al_get_app_name();


return (const char *)tls->new_window_title;
}

Expand Down

0 comments on commit fadf95d

Please sign in to comment.