Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
This commit is contained in:
parent
62d7359fd5
commit
c6b7c0f507
12 changed files with 43 additions and 43 deletions
|
@ -65,7 +65,7 @@ SDL_HasClipboardText(void)
|
|||
if (_this->HasClipboardText) {
|
||||
return _this->HasClipboardText(_this);
|
||||
} else {
|
||||
if ((_this->clipboard_text) && (SDL_strlen(_this->clipboard_text)>0)) {
|
||||
if (_this->clipboard_text && _this->clipboard_text[0] != '\0') {
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
return SDL_FALSE;
|
||||
|
|
|
@ -1453,7 +1453,7 @@ SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata)
|
|||
CHECK_WINDOW_MAGIC(window, NULL);
|
||||
|
||||
/* Input validation */
|
||||
if (name == NULL || SDL_strlen(name) == 0) {
|
||||
if (name == NULL || name[0] == '\0') {
|
||||
SDL_InvalidParamError("name");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1500,7 +1500,7 @@ SDL_GetWindowData(SDL_Window * window, const char *name)
|
|||
CHECK_WINDOW_MAGIC(window, NULL);
|
||||
|
||||
/* Input validation */
|
||||
if (name == NULL || SDL_strlen(name) == 0) {
|
||||
if (name == NULL || name[0] == '\0') {
|
||||
SDL_InvalidParamError("name");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ SDL_bool BE_HasClipboardText(_THIS) {
|
|||
SDL_bool result = SDL_FALSE;
|
||||
char *text = BE_GetClipboardText(_this);
|
||||
if (text) {
|
||||
result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE;
|
||||
result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
|
||||
SDL_free(text);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -95,7 +95,7 @@ Cocoa_HasClipboardText(_THIS)
|
|||
SDL_bool result = SDL_FALSE;
|
||||
char *text = Cocoa_GetClipboardText(_this);
|
||||
if (text) {
|
||||
result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE;
|
||||
result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
|
||||
SDL_free(text);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -137,7 +137,7 @@ WIN_HasClipboardText(_THIS)
|
|||
SDL_bool result = SDL_FALSE;
|
||||
char *text = WIN_GetClipboardText(_this);
|
||||
if (text) {
|
||||
result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE;
|
||||
result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
|
||||
SDL_free(text);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -165,7 +165,7 @@ X11_HasClipboardText(_THIS)
|
|||
SDL_bool result = SDL_FALSE;
|
||||
char *text = X11_GetClipboardText(_this);
|
||||
if (text) {
|
||||
result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE;
|
||||
result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
|
||||
SDL_free(text);
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue