From b90404d8edddbcd8ef9ed49170bed3ffefa106f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Mon, 12 May 2008 16:07:22 +0000 Subject: [PATCH] Use tree instead of list for transport temporary link to speed up sorting --- ajaxui/ajaxui.h | 2 +- ajaxui/ajaxui_config_dvb.c | 16 ++++++++-------- ajaxui/ajaxui_config_transport.c | 16 ++++++++-------- tvhead.h | 4 +++- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/ajaxui/ajaxui.h b/ajaxui/ajaxui.h index 0b2aa302..5435b422 100644 --- a/ajaxui/ajaxui.h +++ b/ajaxui/ajaxui.h @@ -104,7 +104,7 @@ void ajax_config_access_init(void); void ajax_config_transport_init(void); int ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq, - struct th_transport_list *tlist, + struct th_transport_tree *tlist, int ntransports); const char *ajaxui_escape_apostrophe(const char *content); diff --git a/ajaxui/ajaxui_config_dvb.c b/ajaxui/ajaxui_config_dvb.c index 01b20d55..0fcfee38 100644 --- a/ajaxui/ajaxui_config_dvb.c +++ b/ajaxui/ajaxui_config_dvb.c @@ -771,7 +771,7 @@ ajax_dvbmuxeditor(http_connection_t *hc, http_reply_t *hr, tcp_queue_t *tq = &hr->hr_tq; char buf[1000]; th_transport_t *t; - struct th_transport_list head; + struct th_transport_tree tree; int n = 0; if(remain == NULL || (tdmi = dvb_mux_find_by_identifier(remain)) == NULL) @@ -779,17 +779,17 @@ ajax_dvbmuxeditor(http_connection_t *hc, http_reply_t *hr, tdmi_displayname(tdmi, buf, sizeof(buf)); - LIST_INIT(&head); + RB_INIT(&tree); LIST_FOREACH(t, &tdmi->tdmi_transports, tht_mux_link) { if(transport_is_available(t)) { - LIST_INSERT_SORTED(&head, t, tht_tmp_link, dvbsvccmp); + RB_INSERT_SORTED(&tree, t, tht_tmp_link, dvbsvccmp); n++; } } ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, buf); - ajax_transport_build_list(hc, tq, &head, n); + ajax_transport_build_list(hc, tq, &tree, n); ajax_box_end(tq, AJAX_BOX_SIDEBOX); http_output_html(hc, hr); @@ -807,7 +807,7 @@ ajax_dvbmuxall(http_connection_t *hc, http_reply_t *hr, th_dvb_mux_instance_t *tdmi; tcp_queue_t *tq = &hr->hr_tq; th_transport_t *t; - struct th_transport_list head; + struct th_transport_tree tree; int n = 0; char buf[100]; @@ -816,19 +816,19 @@ ajax_dvbmuxall(http_connection_t *hc, http_reply_t *hr, snprintf(buf, sizeof(buf), "All services on %s\n", tda->tda_displayname); - LIST_INIT(&head); + RB_INIT(&tree); LIST_FOREACH(tdmi, &tda->tda_muxes, tdmi_adapter_link) { LIST_FOREACH(t, &tdmi->tdmi_transports, tht_mux_link) { if(transport_is_available(t)) { - LIST_INSERT_SORTED(&head, t, tht_tmp_link, dvbsvccmp); + RB_INSERT_SORTED(&tree, t, tht_tmp_link, dvbsvccmp); n++; } } } ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, buf); - ajax_transport_build_list(hc, tq, &head, n); + ajax_transport_build_list(hc, tq, &tree, n); ajax_box_end(tq, AJAX_BOX_SIDEBOX); http_output_html(hc, hr); diff --git a/ajaxui/ajaxui_config_transport.c b/ajaxui/ajaxui_config_transport.c index b01f39b3..2126bd22 100644 --- a/ajaxui/ajaxui_config_transport.c +++ b/ajaxui/ajaxui_config_transport.c @@ -39,7 +39,7 @@ */ int ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq, - struct th_transport_list *tlist, int numtransports) + struct th_transport_tree *tlist, int numtransports) { th_transport_t *t; ajax_table_t ta; @@ -49,7 +49,7 @@ ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq, /* Select all */ tcp_qprintf(tq, "select_all = function() {\r\n"); - LIST_FOREACH(t, tlist, tht_tmp_link) { + RB_FOREACH(t, tlist, tht_tmp_link) { tcp_qprintf(tq, "$('sel_%s').checked = true;\r\n", t->tht_identifier); @@ -58,7 +58,7 @@ ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq, /* Select none */ tcp_qprintf(tq, "select_none = function() {\r\n"); - LIST_FOREACH(t, tlist, tht_tmp_link) { + RB_FOREACH(t, tlist, tht_tmp_link) { tcp_qprintf(tq, "$('sel_%s').checked = false;\r\n", t->tht_identifier); @@ -67,7 +67,7 @@ ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq, /* Invert selection */ tcp_qprintf(tq, "select_invert = function() {\r\n"); - LIST_FOREACH(t, tlist, tht_tmp_link) { + RB_FOREACH(t, tlist, tht_tmp_link) { tcp_qprintf(tq, "$('sel_%s').checked = !$('sel_%s').checked;\r\n", t->tht_identifier, t->tht_identifier); @@ -76,7 +76,7 @@ ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq, /* Select TV transports */ tcp_qprintf(tq, "select_tv = function() {\r\n"); - LIST_FOREACH(t, tlist, tht_tmp_link) { + RB_FOREACH(t, tlist, tht_tmp_link) { tcp_qprintf(tq, "$('sel_%s').checked = %s;\r\n", t->tht_identifier, @@ -86,7 +86,7 @@ ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq, /* Select unscrambled TV transports */ tcp_qprintf(tq, "select_tv_nocrypt = function() {\r\n"); - LIST_FOREACH(t, tlist, tht_tmp_link) { + RB_FOREACH(t, tlist, tht_tmp_link) { tcp_qprintf(tq, "$('sel_%s').checked = %s;\r\n", t->tht_identifier, @@ -99,7 +99,7 @@ ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq, "var h = new Hash();\r\n" ); - LIST_FOREACH(t, tlist, tht_tmp_link) { + RB_FOREACH(t, tlist, tht_tmp_link) { tcp_qprintf(tq, "if($('sel_%s').checked) {h.set('%s', 'selected') }\r\n", t->tht_identifier, t->tht_identifier); @@ -123,7 +123,7 @@ ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq, "", "Target channel", "", NULL}, (int[]){8,4,4,12,3,12,1}); - LIST_FOREACH(t, tlist, tht_tmp_link) { + RB_FOREACH(t, tlist, tht_tmp_link) { ajax_table_row_start(&ta, t->tht_identifier); ajax_table_cell(&ta, "status", diff --git a/tvhead.h b/tvhead.h index 0b653205..ff17db47 100644 --- a/tvhead.h +++ b/tvhead.h @@ -28,6 +28,7 @@ #include #include #include +#include /* * Commercial status @@ -79,6 +80,7 @@ TAILQ_HEAD(event_queue, event); LIST_HEAD(pvr_rec_list, pvr_rec); TAILQ_HEAD(ref_update_queue, ref_update); LIST_HEAD(th_transport_list, th_transport); +RB_HEAD(th_transport_tree, th_transport); TAILQ_HEAD(th_transport_queue, th_transport); LIST_HEAD(th_dvb_mux_list, th_dvb_mux); LIST_HEAD(th_dvb_mux_instance_list, th_dvb_mux_instance); @@ -424,7 +426,7 @@ typedef struct th_transport { LIST_ENTRY(th_transport) tht_mux_link; - LIST_ENTRY(th_transport) tht_tmp_link; + RB_ENTRY(th_transport) tht_tmp_link; LIST_ENTRY(th_transport) tht_active_link;