summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-08 01:14:41 +0000
committeryoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-08 01:14:41 +0000
commite8d007a131358658444af55a899b55771d958c5c (patch)
tree98d6e0ed0381749c17e779f9a1276c4b4a0336ce
parent4e782c7e5fe60912c69041e1e34a9983af4a3a6d (diff)
downloadchromium_src-e8d007a131358658444af55a899b55771d958c5c.zip
chromium_src-e8d007a131358658444af55a899b55771d958c5c.tar.gz
chromium_src-e8d007a131358658444af55a899b55771d958c5c.tar.bz2
[Files.app] Cache urls of entries before sorting.
toURL() consumes about a half time of filelist draw. In sort, toURL is called by the compare function, which is called many times in sort. The great solution is making toURL faster, but as for now, we cache urls and use it in sort, instead of calling toURL in each call. BUG=367123 TEST=manually. R=hirono@chromium.org Review URL: https://codereview.chromium.org/270573004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269009 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/file_manager/file_manager/foreground/js/directory_contents.js5
-rw-r--r--ui/file_manager/file_manager/foreground/js/metadata/metadata_cache.js4
2 files changed, 8 insertions, 1 deletions
diff --git a/ui/file_manager/file_manager/foreground/js/directory_contents.js b/ui/file_manager/file_manager/foreground/js/directory_contents.js
index 6223883..37125ba 100644
--- a/ui/file_manager/file_manager/foreground/js/directory_contents.js
+++ b/ui/file_manager/file_manager/foreground/js/directory_contents.js
@@ -638,6 +638,11 @@ DirectoryContents.prototype.onNewEntries_ = function(entries) {
var entriesFiltered = [].filter.call(
entries, this.context_.fileFilter.filter.bind(this.context_.fileFilter));
+ // Caching URL to reduce a number of calls of toURL in sort.
+ // This is a temporary solution. We need to fix a root cause of slow toURL.
+ // See crbug.com/370908 for detail.
+ entriesFiltered.forEach(function(entry) { entry.cachedUrl = entry.toURL(); });
+
// Update the filelist without waiting the metadata.
this.fileList_.push.apply(this.fileList_, entriesFiltered);
cr.dispatchSimpleEvent(this, 'scan-updated');
diff --git a/ui/file_manager/file_manager/foreground/js/metadata/metadata_cache.js b/ui/file_manager/file_manager/foreground/js/metadata/metadata_cache.js
index c572578..33082e8 100644
--- a/ui/file_manager/file_manager/foreground/js/metadata/metadata_cache.js
+++ b/ui/file_manager/file_manager/foreground/js/metadata/metadata_cache.js
@@ -325,7 +325,9 @@ MetadataCache.prototype.getOne = function(entry, type, callback) {
* @return {Object} The metadata or null.
*/
MetadataCache.prototype.getCached = function(entry, type) {
- var entryURL = entry.toURL();
+ // Entry.cachedUrl may be set in DirectoryContents.onNewEntries_().
+ // See the comment there for detail.
+ var entryURL = entry.cachedUrl || entry.toURL();
var cache = this.cache_[entryURL];
return cache ? (cache.properties[type] || null) : null;
};