Use tree instead of list for transport temporary link to speed up

sorting
This commit is contained in:
Andreas Öman 2008-05-12 16:07:22 +00:00
parent 2c2de9d969
commit b90404d8ed
4 changed files with 20 additions and 18 deletions

View 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);

View 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);

View 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",

View file

@ -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;