Early out if setting a duplicate window title
Build (All) / Create test plan (push) Waiting to run
Build (All) / level1 (push) Blocked by required conditions
Build (All) / level2 (push) Blocked by required conditions

Setting the window title is an expensive windowing operation, so short circuit it if possible.
This commit is contained in:
Sam Lantinga
2025-02-26 17:10:41 -08:00
parent 56e2955b6a
commit 1ea99bc904
+8 -1
View File
@@ -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);