Revert "- Cut down on strrchr calls inside loops"
This reverts commit f73d9dead3
.
This commit is contained in:
parent
6010c74559
commit
14906fc489
18
core_info.c
18
core_info.c
|
@ -1549,7 +1549,7 @@ static size_t core_info_get_file_id(const char *core_filename,
|
|||
char *s, size_t len)
|
||||
{
|
||||
size_t _len;
|
||||
char *pos = NULL;
|
||||
char *last_underscore = NULL;
|
||||
if (string_is_empty(core_filename))
|
||||
return 0;
|
||||
/* Core file 'id' is filename without extension
|
||||
|
@ -1563,19 +1563,15 @@ static size_t core_info_get_file_id(const char *core_filename,
|
|||
* Since core names include underscore, which is not allowed, but not dot,
|
||||
* which is, we change underscore to dot. Here, we need to change it back.
|
||||
*/
|
||||
for (pos = s; *pos != '\0'; pos++)
|
||||
{
|
||||
if (*pos == '.')
|
||||
*pos = '-';
|
||||
}
|
||||
string_replace_all_chars(s, '.', '_');
|
||||
#endif
|
||||
/* > Remove suffix */
|
||||
pos = (char*)strrchr(s, '_');
|
||||
if ( !string_is_empty(pos)
|
||||
&& !string_is_equal(pos, "_libretro"))
|
||||
last_underscore = (char*)strrchr(s, '_');
|
||||
if ( !string_is_empty(last_underscore)
|
||||
&& !string_is_equal(last_underscore, "_libretro"))
|
||||
{
|
||||
*pos = '\0';
|
||||
_len = pos - s;
|
||||
*last_underscore = '\0';
|
||||
_len = last_underscore - s;
|
||||
}
|
||||
return _len;
|
||||
}
|
||||
|
|
|
@ -791,18 +791,13 @@ static const char* frontend_darwin_get_cpu_model_name(void)
|
|||
|
||||
static enum retro_language frontend_darwin_get_user_language(void)
|
||||
{
|
||||
char *pos;
|
||||
char s[128];
|
||||
CFArrayRef langs = CFLocaleCopyPreferredLanguages();
|
||||
CFStringRef langCode = CFArrayGetValueAtIndex(langs, 0);
|
||||
CFStringGetCString(langCode, s, sizeof(s), kCFStringEncodingUTF8);
|
||||
/* iOS and OS X only support the language ID syntax consisting
|
||||
* of a language designator and optional region or script designator. */
|
||||
for (pos = s; *pos != '\0'; pos++)
|
||||
{
|
||||
if (*pos == '-')
|
||||
*pos = '_';
|
||||
}
|
||||
string_replace_all_chars(s, '-', '_');
|
||||
return retroarch_get_language_from_iso(s);
|
||||
}
|
||||
|
||||
|
|
|
@ -453,7 +453,6 @@ bool manual_content_scan_set_menu_core_name(
|
|||
* struct, if required */
|
||||
if (!string_is_empty(core_info->supported_extensions))
|
||||
{
|
||||
char *pos;
|
||||
strlcpy(
|
||||
scan_settings.file_exts_core,
|
||||
core_info->supported_extensions,
|
||||
|
@ -462,11 +461,7 @@ bool manual_content_scan_set_menu_core_name(
|
|||
/* Core info extensions are delimited by
|
||||
* vertical bars. For internal consistency,
|
||||
* replace them with spaces */
|
||||
for (pos = scan_settings.file_exts_core; *pos != '\0'; pos++)
|
||||
{
|
||||
if (*pos == '|')
|
||||
*pos = ' ';
|
||||
}
|
||||
string_replace_all_chars(scan_settings.file_exts_core, '|', ' ');
|
||||
|
||||
/* Apply standard scrubbing/clean-up
|
||||
* (should not be required, but must handle the
|
||||
|
@ -657,7 +652,6 @@ enum manual_content_scan_playlist_refresh_status
|
|||
scan_settings.file_exts_custom[0] = '\0';
|
||||
else
|
||||
{
|
||||
char *pos;
|
||||
strlcpy(scan_settings.file_exts_custom, file_exts,
|
||||
sizeof(scan_settings.file_exts_custom));
|
||||
|
||||
|
@ -670,11 +664,7 @@ enum manual_content_scan_playlist_refresh_status
|
|||
* to handle the case where a user has
|
||||
* 'corrupted' it by manually tampering with
|
||||
* the playlist file */
|
||||
for (pos = scan_settings.file_exts_custom; *pos != '\0'; pos++)
|
||||
{
|
||||
if (*pos == '|')
|
||||
*pos = ' ';
|
||||
}
|
||||
string_replace_all_chars(scan_settings.file_exts_custom, '|', ' ');
|
||||
manual_content_scan_scrub_file_exts(scan_settings.file_exts_custom);
|
||||
}
|
||||
|
||||
|
@ -1066,14 +1056,7 @@ bool manual_content_scan_get_task_config(
|
|||
* > dir_list_new() expects vertical bar
|
||||
* delimiters, so find and replace */
|
||||
if (!string_is_empty(task_config->file_exts))
|
||||
{
|
||||
char *pos;
|
||||
for (pos = task_config->file_exts; *pos != '\0'; pos++)
|
||||
{
|
||||
if (*pos == ' ')
|
||||
*pos = '|';
|
||||
}
|
||||
}
|
||||
string_replace_all_chars(task_config->file_exts, ' ', '|');
|
||||
|
||||
/* Get DAT file path */
|
||||
if (!string_is_empty(scan_settings.dat_file_path))
|
||||
|
|
|
@ -149,11 +149,8 @@ static int action_get_title_remap_port(
|
|||
snprintf(s, len,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_USER_BINDS),
|
||||
atoi(path) + 1);
|
||||
for (pos = s; *pos != '\0'; ++pos)
|
||||
{
|
||||
if (*pos == '_')
|
||||
*pos = ' ';
|
||||
}
|
||||
while ((pos = strchr(s, '_')))
|
||||
*pos = ' ';
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -2287,7 +2287,7 @@ static void xmb_list_switch_new(xmb_handle_t *xmb,
|
|||
|
||||
static void xmb_set_title(xmb_handle_t *xmb)
|
||||
{
|
||||
char *pos = NULL;
|
||||
char *scrub_char_ptr = NULL;
|
||||
xmb->title_name_alt[0] = '\0';
|
||||
|
||||
if ( (xmb->categories_selection_ptr <= xmb->system_tab_end)
|
||||
|
@ -2324,11 +2324,8 @@ static void xmb_set_title(xmb_handle_t *xmb)
|
|||
}
|
||||
}
|
||||
|
||||
for (pos = xmb->title_name; *pos != '\0'; ++pos)
|
||||
{
|
||||
if (*pos == '/')
|
||||
*pos = '-';
|
||||
}
|
||||
while ((scrub_char_ptr = strchr(xmb->title_name, '/')))
|
||||
*scrub_char_ptr = '-';
|
||||
}
|
||||
|
||||
static xmb_node_t* xmb_get_node(xmb_handle_t *xmb, unsigned i)
|
||||
|
|
|
@ -3446,7 +3446,6 @@ static size_t setting_get_string_representation_uint_menu_thumbnails(
|
|||
|
||||
static void setting_set_string_representation_timedate_date_separator(char *s)
|
||||
{
|
||||
char *pos;
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned menu_timedate_date_separator = settings
|
||||
? settings->uints.menu_timedate_date_separator
|
||||
|
@ -3455,18 +3454,10 @@ static void setting_set_string_representation_timedate_date_separator(char *s)
|
|||
switch (menu_timedate_date_separator)
|
||||
{
|
||||
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
|
||||
for (pos = s; *pos != '\0'; pos++)
|
||||
{
|
||||
if (*pos == '-')
|
||||
*pos = '/';
|
||||
}
|
||||
string_replace_all_chars(s, '-', '/');
|
||||
break;
|
||||
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
|
||||
for (pos = s; *pos != '\0'; pos++)
|
||||
{
|
||||
if (*pos == '-')
|
||||
*pos = '.';
|
||||
}
|
||||
string_replace_all_chars(s, '-', '.');
|
||||
break;
|
||||
case MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN:
|
||||
default:
|
||||
|
|
28
playlist.c
28
playlist.c
|
@ -213,7 +213,6 @@ static void path_replace_base_path_and_convert_to_local_file_system(
|
|||
* replace it with new base content directory */
|
||||
if (string_starts_with_size(in_path, in_oldrefpath, in_oldrefpath_length))
|
||||
{
|
||||
char *pos;
|
||||
size_t in_refpath_length = strlen(in_refpath);
|
||||
memcpy(s, in_refpath, in_refpath_length);
|
||||
memcpy(
|
||||
|
@ -224,18 +223,12 @@ static void path_replace_base_path_and_convert_to_local_file_system(
|
|||
/* If we are running under a Windows filesystem,
|
||||
* '/' characters are not allowed anywhere.
|
||||
* We replace with '\' and hope for the best... */
|
||||
for (pos = s; *pos != '\0'; pos++)
|
||||
{
|
||||
if (*pos == POSIX_PATH_DELIMITER)
|
||||
*pos = WINDOWS_PATH_DELIMITER;
|
||||
}
|
||||
string_replace_all_chars(s,
|
||||
POSIX_PATH_DELIMITER, WINDOWS_PATH_DELIMITER);
|
||||
#else
|
||||
/* Under POSIX filesystem, we replace '\' characters with '/' */
|
||||
for (pos = s; *pos != '\0'; pos++)
|
||||
{
|
||||
if (*pos == WINDOWS_PATH_DELIMITER)
|
||||
*pos = POSIX_PATH_DELIMITER;
|
||||
}
|
||||
string_replace_all_chars(s,
|
||||
WINDOWS_PATH_DELIMITER, POSIX_PATH_DELIMITER);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
@ -2693,23 +2686,14 @@ static bool playlist_read_file(playlist_t *playlist)
|
|||
* lines from the file */
|
||||
for (i = 0; i < PLAYLIST_ENTRIES; i++)
|
||||
{
|
||||
char *pos = NULL;
|
||||
*line_buf[i] = '\0';
|
||||
|
||||
if (!intfstream_gets(file, line_buf[i], sizeof(line_buf[i])))
|
||||
break;
|
||||
/* Ensure line is NULL terminated, regardless of
|
||||
* Windows or Unix line endings */
|
||||
for (pos = line_buf[i]; *pos != '\0'; pos++)
|
||||
{
|
||||
if (*pos == '\r')
|
||||
*pos = '\0';
|
||||
}
|
||||
for (pos = line_buf[i]; *pos != '\0'; pos++)
|
||||
{
|
||||
if (*pos == '\n')
|
||||
*pos = '\0';
|
||||
}
|
||||
string_replace_all_chars(line_buf[i], '\r', '\0');
|
||||
string_replace_all_chars(line_buf[i], '\n', '\0');
|
||||
|
||||
lines_read++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue