diff options
author | Lukasz Stanislawski <l.stanislaws@samsung.com> | 2018-07-19 12:08:19 +0200 |
---|---|---|
committer | Lukasz Stanislawski <l.stanislaws@samsung.com> | 2018-07-19 14:00:13 +0200 |
commit | 76c35090ce15f720a833b93a9f1ce5514710570b (patch) | |
tree | 0b2d9f24ca849562e940d98792a6e2178f20ddc2 | |
parent | 097b68001bb37e3388200de2dd3ced393a718bd1 (diff) | |
download | ttsd-worker-task-76c35090ce15f720a833b93a9f1ce5514710570b.tar.gz ttsd-worker-task-76c35090ce15f720a833b93a9f1ce5514710570b.tar.bz2 ttsd-worker-task-76c35090ce15f720a833b93a9f1ce5514710570b.zip |
process: micro optimization
Change-Id: Ib21b5172763663d83e160016f645e276a8c0ad88
-rw-r--r-- | src/proc-scanner.c | 12 | ||||
-rw-r--r-- | src/process.c | 2 |
2 files changed, 6 insertions, 8 deletions
diff --git a/src/proc-scanner.c b/src/proc-scanner.c index 2798e42..b2fdf9e 100644 --- a/src/proc-scanner.c +++ b/src/proc-scanner.c @@ -52,11 +52,11 @@ void proctab_resize(struct proctab *tab, int new_max) tab->max = new_max; } -void proctab_append(struct proctab *tab, struct process *proc) +void proctab_move_back(struct proctab *tab, struct process *proc) { if (tab->size >= tab->max) proctab_resize(tab, tab->max *= 2); - tab->processes[tab->size++] = *proc; + process_move(&tab->processes[tab->size++],proc); } void proctab_reset(struct proctab *tab) @@ -142,15 +142,13 @@ static bool _proc_scanner_read_pid(int pid, void *user_data) if (!proc) { process_init(pid, &proc_new); proc = &proc_new; - } else { - process_move(&proc_new, proc); } - if (process_update(&proc_new) != 0) { - process_shutdown(&proc_new); + if (process_update(proc) != 0) { + process_shutdown(proc); return true; } - proctab_append(&scanner->current, &proc_new); + proctab_move_back(&scanner->current, proc); return true; } diff --git a/src/process.c b/src/process.c index e5f7753..70f4bb0 100644 --- a/src/process.c +++ b/src/process.c @@ -78,11 +78,11 @@ void process_shutdown(struct process *proc) if (!proc) return; free(proc->appid); free(proc->exe); + memset(proc, 0x0, sizeof(struct process)); } void process_move(struct process *dst, struct process *src) { - process_shutdown(dst); memcpy(dst, src, sizeof(struct process)); src->appid = NULL; src->exe = NULL; |