mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
Early out if setting a duplicate window title
Setting the window title is an expensive windowing operation, so short circuit it if possible.
This commit is contained in:
@@ -2767,9 +2767,16 @@ bool SDL_SetWindowTitle(SDL_Window *window, const char *title)
|
||||
if (title == window->title) {
|
||||
return true;
|
||||
}
|
||||
if (!title) {
|
||||
title = "";
|
||||
}
|
||||
if (window->title && SDL_strcmp(title, window->title) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_free(window->title);
|
||||
|
||||
window->title = SDL_strdup(title ? title : "");
|
||||
window->title = SDL_strdup(title);
|
||||
|
||||
if (_this->SetWindowTitle) {
|
||||
_this->SetWindowTitle(_this, window);
|
||||
|
Reference in New Issue
Block a user