From 07378b9203f949fb7a475115051edb09f134d8ff Mon Sep 17 00:00:00 2001 From: Hector Martin Date: Mon, 12 Oct 2009 06:10:50 +0200 Subject: optimize: persist fdlist for duration of main_loop constant malloc and realloc was wasting lots of time --- daemon/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'daemon') diff --git a/daemon/main.c b/daemon/main.c index 893f26d..f85d034 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -138,6 +138,7 @@ int main_loop(int listenfd) int to, cnt, i, dto; struct fdlist pollfds; + fdlist_create(&pollfds); while(!should_exit) { usbmuxd_log(LL_FLOOD, "main_loop iteration"); to = usb_get_timeout(); @@ -147,7 +148,7 @@ int main_loop(int listenfd) if(dto < to) to = dto; - fdlist_create(&pollfds); + fdlist_reset(&pollfds); fdlist_add(&pollfds, FD_LISTEN, listenfd, POLLIN); usb_get_fds(&pollfds); client_get_fds(&pollfds); @@ -201,8 +202,8 @@ int main_loop(int listenfd) } } } - fdlist_free(&pollfds); } + fdlist_free(&pollfds); return 0; } -- cgit v1.1-32-gdbae