Skip to content

Commit cb1ebb7

Browse files
committed
(input_driver.c) Get rid of a lot of string_is_empty calls
1 parent 43d6727 commit cb1ebb7

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

input/input_driver.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,7 +3221,7 @@ void input_overlay_auto_rotate_(
32213221
screen_orientation = OVERLAY_ORIENTATION_LANDSCAPE;
32223222

32233223
/* Get orientation of active overlay */
3224-
if (!string_is_empty(ol->active->name))
3224+
if (ol->active->name && *ol_active->name)
32253225
{
32263226
if (strstr(ol->active->name, "landscape"))
32273227
active_overlay_orientation = OVERLAY_ORIENTATION_LANDSCAPE;
@@ -3247,7 +3247,7 @@ void input_overlay_auto_rotate_(
32473247
if (!desc)
32483248
continue;
32493249

3250-
if (!string_is_empty(desc->next_index_name))
3250+
if (desc->next_index_name && *desc->next_index_name)
32513251
{
32523252
bool next_overlay_found = false;
32533253
if (active_overlay_orientation == OVERLAY_ORIENTATION_LANDSCAPE)
@@ -4245,7 +4245,7 @@ size_t input_config_get_bind_string_joykey(
42454245
(unsigned)bind->joykey);
42464246
}
42474247

4248-
if (!string_is_empty(suffix))
4248+
if (suffix && *suffix)
42494249
_len += snprintf(s + _len, len - _len, " %s", suffix);
42504250

42514251
return _len;
@@ -4273,7 +4273,7 @@ size_t input_config_get_bind_string_joyaxis(
42734273
_len += snprintf(s + _len, len - _len, "+%u",
42744274
(unsigned)AXIS_POS_GET(bind->joyaxis));
42754275

4276-
if (!string_is_empty(suffix))
4276+
if (suffix && *suffix)
42774277
_len += snprintf(s + _len, len - _len, " %s", suffix);
42784278

42794279
return _len;
@@ -5261,7 +5261,7 @@ static void input_config_reindex_device_names(input_driver_state_t *input_st)
52615261
{
52625262
const char *next_device_name = input_config_get_device_name(j);
52635263

5264-
if (string_is_empty(next_device_name))
5264+
if (!next_device_name || !*next_device_name)
52655265
continue;
52665266

52675267
/* Check if names match */
@@ -5356,7 +5356,7 @@ size_t input_config_get_device_name_size(unsigned port)
53565356
void input_config_set_device_name(unsigned port, const char *name)
53575357
{
53585358
input_driver_state_t *input_st = &input_driver_st;
5359-
if (string_is_empty(name))
5359+
if (!name || !*name)
53605360
return;
53615361

53625362
strlcpy(input_st->input_device_info[port].name, name,
@@ -5368,23 +5368,23 @@ void input_config_set_device_name(unsigned port, const char *name)
53685368
void input_config_set_device_display_name(unsigned port, const char *name)
53695369
{
53705370
input_driver_state_t *input_st = &input_driver_st;
5371-
if (!string_is_empty(name))
5371+
if (name && *name)
53725372
strlcpy(input_st->input_device_info[port].display_name, name,
53735373
sizeof(input_st->input_device_info[port].display_name));
53745374
}
53755375

53765376
void input_config_set_device_config_name(unsigned port, const char *name)
53775377
{
53785378
input_driver_state_t *input_st = &input_driver_st;
5379-
if (!string_is_empty(name))
5379+
if (name && *name)
53805380
strlcpy(input_st->input_device_info[port].config_name, name,
53815381
sizeof(input_st->input_device_info[port].config_name));
53825382
}
53835383

53845384
void input_config_set_device_joypad_driver(unsigned port, const char *driver)
53855385
{
53865386
input_driver_state_t *input_st = &input_driver_st;
5387-
if (!string_is_empty(driver))
5387+
if (driver && *driver)
53885388
strlcpy(input_st->input_device_info[port].joypad_driver, driver,
53895389
sizeof(input_st->input_device_info[port].joypad_driver));
53905390
}
@@ -5454,13 +5454,13 @@ void input_config_set_mouse_display_name(unsigned port, const char *name)
54545454
name_ascii[0] = '\0';
54555455

54565456
/* Strip non-ASCII characters */
5457-
if (!string_is_empty(name))
5457+
if (name && *name)
54585458
{
54595459
string_copy_only_ascii(name_ascii, name);
54605460
string_trim_whitespace(name_ascii);
54615461
}
54625462

5463-
if (!string_is_empty(name_ascii))
5463+
if (name_ascii && *name_ascii)
54645464
strlcpy(input_st->input_mouse_info[port].display_name, name_ascii,
54655465
sizeof(input_st->input_mouse_info[port].display_name));
54665466
}
@@ -5514,7 +5514,9 @@ void config_read_keybinds_conf(void *data)
55145514
prefix[0] = '\0';
55155515
input_config_get_prefix(prefix, sizeof(prefix), i, meta);
55165516

5517-
if (!btn || string_is_empty(prefix))
5517+
if (!prefix || !*prefix)
5518+
continue;
5519+
if (!btn)
55185520
continue;
55195521

55205522
fill_pathname_join_delim(str, prefix, btn, '_', sizeof(str));
@@ -5524,7 +5526,7 @@ void config_read_keybinds_conf(void *data)
55245526
input_keyboard_mapping_bits(0, bind->key);
55255527

55265528
entry = config_get_entry(conf, str);
5527-
if (entry && !string_is_empty(entry->value))
5529+
if (entry && entry->value && *entry->value)
55285530
bind->key = input_config_translate_str_to_rk(
55295531
entry->value, strlen(entry->value));
55305532

@@ -5951,7 +5953,7 @@ static const char *input_overlay_path(bool want_osk)
59515953
/* try based on the playlist entry first */
59525954
if (playlist)
59535955
{
5954-
if (!string_is_empty(content_path))
5956+
if (content_path && *content_path)
59555957
{
59565958
const struct playlist_entry *entry = NULL;
59575959
playlist_get_index_by_path(playlist, content_path, &entry);
@@ -5994,7 +5996,7 @@ static const char *input_overlay_path(bool want_osk)
59945996
}
59955997

59965998
/* maybe based on the content's directory name */
5997-
if (!string_is_empty(content_path))
5999+
if (content_path && *content_path)
59986000
{
59996001
char dirname[DIR_MAX_LENGTH];
60006002
fill_pathname_parent_dir_name(dirname, content_path, sizeof(dirname));

0 commit comments

Comments
 (0)