(tasks) Don't do implicit memsets in crucial performance-oriented code

This commit is contained in:
twinaphex 2016-10-08 18:31:43 +02:00
parent 81a7f7bf68
commit 1388220866
6 changed files with 45 additions and 16 deletions

View File

@ -85,7 +85,7 @@ int menu_dialog_iterate(char *s, size_t len, const char *label)
case MENU_DIALOG_HELP_CONTROLS:
{
unsigned i;
char s2[PATH_MAX_LENGTH] = {0};
char s2[PATH_MAX_LENGTH];
const unsigned binds[] = {
RETRO_DEVICE_ID_JOYPAD_UP,
RETRO_DEVICE_ID_JOYPAD_DOWN,
@ -113,6 +113,8 @@ int menu_dialog_iterate(char *s, size_t len, const char *label)
keybind, auto_bind, sizeof(desc[i]));
}
s2[0] = '\0';
menu_hash_get_help_enum(MENU_ENUM_LABEL_VALUE_MENU_ENUM_CONTROLS_PROLOG,
s2, sizeof(s2));

View File

@ -144,7 +144,9 @@ static int task_database_iterate_playlist(
database_state_handle_t *db_state,
database_info_handle_t *db, const char *name)
{
char parent_dir[PATH_MAX_LENGTH] = {0};
char parent_dir[PATH_MAX_LENGTH];
parent_dir[0] = '\0';
path_parent_dir(parent_dir);
@ -226,10 +228,10 @@ static int database_info_list_iterate_found_match(
const char *archive_name
)
{
char db_crc[PATH_MAX_LENGTH] = {0};
char db_playlist_path[PATH_MAX_LENGTH] = {0};
char db_playlist_base_str[PATH_MAX_LENGTH] = {0};
char entry_path_str[PATH_MAX_LENGTH] = {0};
char db_crc[PATH_MAX_LENGTH];
char db_playlist_path[PATH_MAX_LENGTH];
char db_playlist_base_str[PATH_MAX_LENGTH];
char entry_path_str[PATH_MAX_LENGTH];
playlist_t *playlist = NULL;
settings_t *settings = config_get_ptr();
const char *db_path =
@ -239,6 +241,11 @@ static int database_info_list_iterate_found_match(
database_info_t *db_info_entry =
&db_state->info->list[db_state->entry_index];
db_crc[0] = '\0';
db_playlist_path[0] = '\0';
db_playlist_base_str[0] = '\0';
entry_path_str[0] = '\0';
fill_short_pathname_representation_noext(db_playlist_base_str,
db_path, sizeof(db_playlist_base_str));
@ -396,10 +403,12 @@ static int task_database_iterate_playlist_lutro(
database_info_handle_t *db,
const char *path)
{
char db_playlist_path[PATH_MAX_LENGTH] = {0};
char db_playlist_path[PATH_MAX_LENGTH];
playlist_t *playlist = NULL;
settings_t *settings = config_get_ptr();
db_playlist_path[0] = '\0';
fill_pathname_join(db_playlist_path,
settings->directory.playlist,
file_path_str(FILE_PATH_LUTRO_PLAYLIST),
@ -409,7 +418,9 @@ static int task_database_iterate_playlist_lutro(
if(!playlist_entry_exists(playlist, path, file_path_str(FILE_PATH_DETECT)))
{
char game_title[PATH_MAX_LENGTH] = {0};
char game_title[PATH_MAX_LENGTH];
game_title[0] = '\0';
fill_short_pathname_representation_noext(game_title,
path, sizeof(game_title));

View File

@ -399,7 +399,9 @@ int find_first_data_track(const char *cue_path,
{
if (string_is_equal(tmp_token, "FILE"))
{
char cue_dir[PATH_MAX_LENGTH] = {0};
char cue_dir[PATH_MAX_LENGTH];
cue_dir[0] = '\0';
fill_pathname_basedir(cue_dir, cue_path, sizeof(cue_dir));

View File

@ -82,9 +82,11 @@ static int file_decompressed(const char *name, const char *valid_exts,
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
uint32_t crc32, struct archive_extract_userdata *userdata)
{
char path[PATH_MAX_LENGTH] = {0};
char path[PATH_MAX_LENGTH];
decompress_state_t *dec = userdata->dec;
path[0] = '\0';
/* Ignore directories. */
if (name[strlen(name) - 1] == '/' || name[strlen(name) - 1] == '\\')
goto next_file;

View File

@ -236,7 +236,7 @@ void *task_push_http_transfer(const char *url, bool mute, const char *type,
retro_task_callback_t cb, void *user_data)
{
task_finder_data_t find_data;
char tmp[PATH_MAX_LENGTH] = {0};
char tmp[PATH_MAX_LENGTH];
struct http_connection_t *conn = NULL;
retro_task_t *t = NULL;
http_handle_t *http = NULL;
@ -244,6 +244,8 @@ void *task_push_http_transfer(const char *url, bool mute, const char *type,
if (string_is_empty(url))
return NULL;
tmp[0] = '\0';
find_data.func = task_http_finder;
find_data.userdata = (void*)url;

View File

@ -60,10 +60,13 @@ static void task_overlay_load_desc_image(
struct overlay *input_overlay,
unsigned ol_idx, unsigned desc_idx)
{
char overlay_desc_image_key[64] = {0};
char image_path[PATH_MAX_LENGTH] = {0};
char overlay_desc_image_key[64];
char image_path[PATH_MAX_LENGTH];
config_file_t *conf = loader->conf;
overlay_desc_image_key[0] = '\0';
image_path[0] = '\0';
snprintf(overlay_desc_image_key, sizeof(overlay_desc_image_key),
"overlay%u_desc%u_overlay", ol_idx, desc_idx);
@ -71,7 +74,10 @@ static void task_overlay_load_desc_image(
image_path, sizeof(image_path)))
{
struct texture_image image_tex;
char path[PATH_MAX_LENGTH] = {0};
char path[PATH_MAX_LENGTH];
path[0] = '\0';
fill_pathname_resolve_relative(path, loader->overlay_path,
image_path, sizeof(path));
@ -473,6 +479,7 @@ static void task_overlay_deferred_load(retro_task_t *task)
for (i = 0; i < loader->pos_increment; i++, loader->pos++)
{
char tmp_str[PATH_MAX_LENGTH];
float tmp_float = 0.0;
bool tmp_bool = false;
char conf_key[64] = {0};
@ -480,7 +487,6 @@ static void task_overlay_deferred_load(retro_task_t *task)
struct texture_image *texture_img = NULL;
struct overlay_desc *overlay_desc = NULL;
struct overlay *overlay = NULL;
char tmp_str[PATH_MAX_LENGTH] = {0};
bool to_cont = loader->pos < loader->size;
if (!to_cont)
@ -490,6 +496,8 @@ static void task_overlay_deferred_load(retro_task_t *task)
break;
}
tmp_str[0] = '\0';
overlay = &loader->overlays[loader->pos];
snprintf(overlay->config.descs.key,
@ -562,7 +570,9 @@ static void task_overlay_deferred_load(retro_task_t *task)
if (!string_is_empty(overlay->config.paths.path))
{
struct texture_image image_tex;
char overlay_resolved_path[PATH_MAX_LENGTH] = {0};
char overlay_resolved_path[PATH_MAX_LENGTH];
overlay_resolved_path[0] = '\0';
fill_pathname_resolve_relative(overlay_resolved_path,
loader->overlay_path,