Cache relative paths instead of using an angular filter.
This will improve the performance a lot. First load performance may suffer a bit, though. Also, the leading "./" is skipped now, as this causes additional string ops, which turn out to be particularly harmful in some cases (slots vs heaps aka. shortstrings in spidermonkey, allocation overhead). And the leading "./" is not really required anymore.
This commit is contained in:
parent
89005aa168
commit
09120284c5
|
@ -50,7 +50,6 @@
|
|||
<script src="js/directives/fselect.js"></script>
|
||||
|
||||
<script src="js/filters/bytes.js"></script>
|
||||
<script src="js/filters/path.js"></script>
|
||||
|
||||
<script src="js/services/constants.js"></script>
|
||||
<script src="js/services/deps.js"></script>
|
||||
|
@ -508,7 +507,7 @@
|
|||
<li class="label" title="Piece Length"><i class="icon-puzzle-piece"></i> Length <span class="download-pieceLength">{{download.pieceLength | blength}}</span></li>
|
||||
</ul>
|
||||
<ul class="download-files hidden-phone download-item">
|
||||
<li class="label" ng-repeat="file in download.files">{{file.path | prelative:download.dir}} ({{file.length | blength}})</li>
|
||||
<li class="label" ng-repeat="file in download.files">{{file.relpath}} ({{file.length | blength}})</li>
|
||||
</ul>
|
||||
<div ng-show="hasStatus(download, 'active')" class="download-item">
|
||||
<div class="download-graph" dspeed="download.downloadSpeed" uspeed="download.uploadSpeed" dgraph draw="!download.collapsed"></div>
|
||||
|
|
|
@ -12,6 +12,10 @@ function(
|
|||
scope, rpc, utils, alerts, modals,
|
||||
fsettings, activeInclude, waitingExclude, window
|
||||
) {
|
||||
|
||||
var re_slashes = /\\/g;
|
||||
var slash = "/";
|
||||
|
||||
scope.active = [], scope.waiting = [], scope.stopped = [];
|
||||
scope.gstats = {};
|
||||
|
||||
|
@ -192,9 +196,16 @@ function(
|
|||
if (files) {
|
||||
var cfiles = ctx["files"] || (ctx["files"] = []);
|
||||
for (var i = 0; i < files.length; ++i) {
|
||||
var file = cfiles[i] || (cfiles[i] = {});
|
||||
file.path = files[i].path;
|
||||
file.length = files[i].length;
|
||||
var cfile = cfiles[i] || (cfiles[i] = {});
|
||||
var file = files[i];
|
||||
if (file.path !== cfile.path) {
|
||||
cfile.path = file.path;
|
||||
cfile.length = file.length;
|
||||
cfile.relpath = file.path.replace(re_slashes, slash);
|
||||
if (!cfile.relpath.startsWith("[")) { // METADATA
|
||||
cfile.relpath = cfile.relpath.substr(ctx.dir.length + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
cfiles.length = files.length;
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
// returns the relative path from base
|
||||
angular.module('webui.filters.path', [])
|
||||
.filter('prelative', function() {
|
||||
return function(path, base) {
|
||||
return path.replace(/\\/g, '/')
|
||||
.replace(base.replace(/\\/, '/'), '.');
|
||||
};
|
||||
});
|
|
@ -3,7 +3,7 @@ var webui = angular.module('webui', [
|
|||
'webui.services.constants', 'webui.services.rpc',
|
||||
'webui.services.modals', 'webui.services.alerts',
|
||||
'webui.services.settings', 'webui.services.settings.filters',
|
||||
'webui.filters.bytes', 'webui.filters.path',
|
||||
'webui.filters.bytes',
|
||||
'webui.directives.chunkbar', 'webui.directives.dgraph', 'webui.directives.fselect',
|
||||
'webui.ctrls.download', 'webui.ctrls.nav', 'webui.ctrls.modal', 'webui.ctrls.alert',
|
||||
'webui.ctrls.props',
|
||||
|
|
Loading…
Reference in New Issue
Block a user