mirror of
https://github.com/libretro/RetroArch
synced 2025-04-03 10:21:31 +00:00
(task_database.c) Optimizations:
- strlen was being called on path for each loop iteration, when path is not subject to change - do it once outside - String copying was being performed even when the string would equal a string not subject to change
This commit is contained in:
parent
32a6bd021c
commit
f22b077887
@ -643,27 +643,26 @@ static int database_info_list_iterate_end_no_match(
|
|||||||
if (archive_list && archive_list->size > 0)
|
if (archive_list && archive_list->size > 0)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
size_t path_len = strlen(path);
|
||||||
|
|
||||||
for (i = 0; i < archive_list->size; i++)
|
for (i = 0; i < archive_list->size; i++)
|
||||||
{
|
{
|
||||||
char new_path[PATH_MAX_LENGTH];
|
|
||||||
size_t path_len = strlen(path);
|
|
||||||
|
|
||||||
new_path[0] = '\0';
|
|
||||||
|
|
||||||
strlcpy(new_path, path, sizeof(new_path));
|
|
||||||
|
|
||||||
if (path_len + strlen(archive_list->elems[i].data)
|
if (path_len + strlen(archive_list->elems[i].data)
|
||||||
+ 1 < PATH_MAX_LENGTH)
|
+ 1 < PATH_MAX_LENGTH)
|
||||||
{
|
{
|
||||||
|
char new_path[PATH_MAX_LENGTH];
|
||||||
|
new_path[0] = '\0';
|
||||||
|
strlcpy(new_path, path, sizeof(new_path));
|
||||||
new_path[path_len] = '#';
|
new_path[path_len] = '#';
|
||||||
strlcpy(new_path + path_len + 1,
|
strlcpy(new_path + path_len + 1,
|
||||||
archive_list->elems[i].data,
|
archive_list->elems[i].data,
|
||||||
sizeof(new_path) - path_len);
|
sizeof(new_path) - path_len);
|
||||||
|
string_list_append(db->list, new_path,
|
||||||
|
archive_list->elems[i].attr);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
string_list_append(db->list, new_path,
|
string_list_append(db->list, path,
|
||||||
archive_list->elems[i].attr);
|
archive_list->elems[i].attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
string_list_free(archive_list);
|
string_list_free(archive_list);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user