session OPTIMIZE deleting from an array
Instead of moving all the items after the
deleted one, place only the last one there
instead.
diff --git a/src/session_server.c b/src/session_server.c
index 2f86c1f..a0f8239 100644
--- a/src/session_server.c
+++ b/src/session_server.c
@@ -480,7 +480,7 @@
for (i = 0; i < ps->session_count; ++i) {
if (ps->sessions[i].session == session) {
--ps->session_count;
- memmove(&ps->sessions[i], &ps->sessions[i + 1], ps->session_count - i);
+ memcpy(&ps->sessions[i], &ps->sessions[ps->session_count], sizeof *ps->sessions);
return 0;
}
}
@@ -774,7 +774,7 @@
free(server_opts.binds[i].address);
--server_opts.bind_count;
- memmove(&server_opts.binds[i], &server_opts.binds[i + 1], (server_opts.bind_count - i) * sizeof *server_opts.binds);
+ memcpy(&server_opts.binds[i], &server_opts.binds[server_opts.bind_count], sizeof *server_opts.binds);
ret = 0;
}