1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-20 21:26:53 +00:00

(trunk web) slightly faster Transmission.refilter(). Modify Transmission.refreshFilterPopup(), Torrent.getCollatedName(), and Torrent.getCollatedTrackers() for clarity.

This commit is contained in:
Jordan Lee 2011-08-27 00:22:56 +00:00
parent 4517155353
commit 9cb9fd56d9
2 changed files with 17 additions and 22 deletions

View file

@ -282,20 +282,14 @@ Torrent.prototype =
}, },
getCollatedName: function() { getCollatedName: function() {
var f = this.fields; var f = this.fields;
if (!f.collatedName) { if (!f.collatedName && f.name)
var name = this.fields.name; f.collatedName = f.name.toLowerCase();
if (name)
f.collatedName = name.toLowerCase();
}
return f.collatedName || ''; return f.collatedName || '';
}, },
getCollatedTrackers: function() { getCollatedTrackers: function() {
var f = this.fields; var f = this.fields;
if (!f.collatedTrackers) { if (!f.collatedTrackers && f.trackers)
var trackers = this.getTrackers(); f.collatedTrackers = this.collateTrackers(f.trackers);
if (trackers)
f.collatedTrackers = this.collateTrackers(trackers);
}
return f.collatedTrackers || ''; return f.collatedTrackers || '';
}, },

View file

@ -1104,6 +1104,8 @@ Transmission.prototype =
var ids = this.getSelectedTorrentIds(); var ids = this.getSelectedTorrentIds();
if (ids && ids.length) { if (ids && ids.length) {
var fields = ['id'].concat(Torrent.Fields.StatsExtra); var fields = ['id'].concat(Torrent.Fields.StatsExtra);
if (full)
fields = fields.concat(Torrent.Fields.InfoExtra);
this.remote.updateTorrents(ids, fields, this.updateFromTorrentGet, this); this.remote.updateTorrents(ids, fields, this.updateFromTorrentGet, this);
} }
} }
@ -1956,11 +1958,12 @@ Transmission.prototype =
delete this.refilterTimer; delete this.refilterTimer;
// make a filtered, sorted array of our torrents // make a filtered, sorted array of our torrents
var keep = []; var filter_mode = this[Prefs._FilterMode];
var all_torrents = this.getAllTorrents(); var filter_text = this._current_search;
for (var i=0, t; t=all_torrents[i]; ++i) var filter_tracker = this.filterTracker;
if (t.test(this[Prefs._FilterMode], this._current_search, this.filterTracker)) var keep = $.grep(this.getAllTorrents(), function(t) {
keep.push(t); return t.test(filter_mode, filter_text, filter_tracker);
});
Torrent.sortTorrents(keep, this[Prefs._SortMethod], this[Prefs._SortDirection]); Torrent.sortTorrents(keep, this[Prefs._SortMethod], this[Prefs._SortDirection]);
// maybe rebuild the rows // maybe rebuild the rows
@ -1973,10 +1976,11 @@ Transmission.prototype =
var tr = this; var tr = this;
var rows = [ ]; var rows = [ ];
var fragment = document.createDocumentFragment(); var fragment = document.createDocumentFragment();
var renderer = this.torrentRenderer;
for (var i=0, tor; tor=keep[i]; ++i) for (var i=0, tor; tor=keep[i]; ++i)
{ {
var is_selected = old_sel.indexOf(tor) !== -1; var is_selected = old_sel.indexOf(tor) !== -1;
var row = new TorrentRow(this.torrentRenderer, this, tor, is_selected); var row = new TorrentRow(renderer, this, tor, is_selected);
row.setEven((i+1) % 2 == 0); row.setEven((i+1) % 2 == 0);
if (is_selected) if (is_selected)
new_sel_count++; new_sel_count++;
@ -1985,8 +1989,8 @@ Transmission.prototype =
if (b) if (b)
$(b).click({r:row}, function(ev) {tr.onToggleRunningClicked(ev);}); $(b).click({r:row}, function(ev) {tr.onToggleRunningClicked(ev);});
} }
$(row.getElement()).click({r: row}, function(ev) {tr.onRowClicked(ev,ev.data.r);}); $(row.getElement()).click({r: row}, function(ev) {tr.onRowClicked(ev,ev.data.r);})
$(row.getElement()).dblclick(function() { tr.toggleInspector();}); .dblclick(function() {tr.toggleInspector();});
fragment.appendChild(row.getElement()); fragment.appendChild(row.getElement());
rows.push(row); rows.push(row);
} }
@ -2058,10 +2062,7 @@ Transmission.prototype =
***/ ***/
var trackers = this.getTrackers(); var trackers = this.getTrackers();
var names = []; var names = Object.keys(trackers).sort();
for (var name in trackers)
names.push(name);
names.sort();
var fragment = document.createDocumentFragment(); var fragment = document.createDocumentFragment();
var div = document.createElement('div'); var div = document.createElement('div');