]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Use tree instead of list for transport temporary link to speed up
authorAndreas Öman <andreas@lonelycoder.com>
Mon, 12 May 2008 16:07:22 +0000 (16:07 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Mon, 12 May 2008 16:07:22 +0000 (16:07 +0000)
sorting

ajaxui/ajaxui.h
ajaxui/ajaxui_config_dvb.c
ajaxui/ajaxui_config_transport.c
tvhead.h

index 0b2aa302f4bb252ba3e682b608a7052bef6b8523..5435b422d8304490f1968db17ec0a9f4018c0f78 100644 (file)
@@ -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);
index 01b20d5560565ca6398d5a95bb4b3fb99e5423f1..0fcfee3876717bb21d5936414b4f54e15f8950c8 100644 (file)
@@ -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);
index b01f39b3ccbd55d9531fdc881bfcdc2972273c5d..2126bd2212aca218a6b289316da43b40af4c64a8 100644 (file)
@@ -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", 
index 0b65320558e7cebf56e706b3cc58e52744bd52c8..ff17db47bba8cb64e78021f6bc7a2200534fd9fd 100644 (file)
--- a/tvhead.h
+++ b/tvhead.h
@@ -28,6 +28,7 @@
 #include <libhts/avg.h>
 #include <libhts/hts_strtab.h>
 #include <libavcodec/avcodec.h>
+#include <libhts/redblack.h>
 
 /*
  * 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;