diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2020-08-08 12:07:17 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2020-08-08 12:07:17 +0200 |
commit | c4fa2aff45e974d7042410587c6c9ae2487f3f5d (patch) | |
tree | 0f956947519e0ffc7cc4574c06f39b80e5061f56 | |
parent | fc18e73c7e66c7a03381312937434aac7210ca6b (diff) |
server: Performance fix in user_data
-rw-r--r-- | user_data.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/user_data.c b/user_data.c index 6b9b041..125a6b4 100644 --- a/user_data.c +++ b/user_data.c @@ -61,8 +61,10 @@ void userdata_unregister(i64 userid,int fd){ if(i==data->len){ die("userdata_unregister(%" PRIi64 ", %d) while nonexistent",userid,fd); } - memmove(data->fds+i,data->fds+i+1,data->len-i-1); - memmove(data->last_active+i,data->last_active+i+1,data->len-i-1); + if(i<data->len-1){ + data->fds[i]=data->fds[data->len-1]; + data->last_active[i]=data->last_active[data->len-1]; + } data->len--; if(data->len==0){ ht_delete(user_hash,userid); |