[ARVADOS] updated: 90ecd742ac7b8560634d6f9ad557d149954596ad
git at public.curoverse.com
git at public.curoverse.com
Thu Dec 4 17:45:35 EST 2014
Summary of changes:
.../app/assets/javascripts/arvados_client.js | 41 +++++++++++++---------
1 file changed, 24 insertions(+), 17 deletions(-)
via 90ecd742ac7b8560634d6f9ad557d149954596ad (commit)
from e320b9009a294a81a68e56e1998782c445d1affe (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 90ecd742ac7b8560634d6f9ad557d149954596ad
Author: Tom Clegg <tom at curoverse.com>
Date: Thu Dec 4 17:43:49 2014 -0500
3781: Use regexp instead of split: avoid making big arrays when working on big manifests.
diff --git a/apps/workbench/app/assets/javascripts/arvados_client.js b/apps/workbench/app/assets/javascripts/arvados_client.js
index 584928f..eaffaf7 100644
--- a/apps/workbench/app/assets/javascripts/arvados_client.js
+++ b/apps/workbench/app/assets/javascripts/arvados_client.js
@@ -44,38 +44,45 @@ function ArvadosClient(arvadosApiToken, arvadosDiscoveryUri) {
});
}
- function uniqueNameForManifest(manifest, streamName, origName) {
+ function uniqueNameForManifest(manifest, newStreamName, origName) {
// Return an (escaped) filename starting with (unescaped)
- // origName that won't conflict with any existing names in
- // the manifest if saved under streamName. streamName must
- // be exactly as given in the manifest, e.g., "." or
- // "./foo" or "./foo/bar".
+ // origName that won't conflict with any existing names in the
+ // manifest if saved under newStreamName. newStreamName must
+ // be exactly as given in the manifest, e.g., "." or "./foo"
+ // or "./foo/bar".
//
// Example:
//
- // unique('./foo [...] 0:0:bar\040baz\n', '.', 'foo/bar baz')
+ // uniqueNameForManifest('./foo [...] 0:0:bar\\040baz.txt\n', '.',
+ // 'foo/bar baz.txt')
// =>
- // 'foo/bar\\040baz\\040(1)'
+ // 'foo/bar\\040baz\\040(1).txt'
var newName;
var nameStub = origName;
var suffixInt = null;
var ok = false;
+ var lineMatch, linesRe = /[^\n]+/g;
+ var streamNameMatch, streamNameRe = /^\S+/;
+ var fileTokenMatch, fileTokensRe = / \d+:\d+:(\S+)/g;
while (!ok) {
ok = true;
// Add ' (N)' before the filename extension, if any.
newName = (!suffixInt ? nameStub :
nameStub.replace(/(\.[^.]*)?$/, ' ('+suffixInt+')$1')).
replace(/ /g, '\\040');
- $.each(manifest.split('\n'), function(_, line) {
- var i, match, foundName;
- var toks = line.split(' ');
- for (var i=1; i<toks.length && ok; i++)
- if (match = toks[i].match(/^\d+:\d+:(\S+)/))
- if (toks[0] + '/' + match[1] === streamName + '/' + newName) {
- suffixInt = (suffixInt || 0) + 1;
- ok = false;
- }
- });
+ while (ok && null !==
+ (lineMatch = linesRe.exec(manifest))) {
+ streamNameMatch = streamNameRe.exec(lineMatch[0]);
+ while (ok && null !==
+ (fileTokenMatch = fileTokensRe.exec(lineMatch[0]))) {
+ if (streamNameMatch[0] + '/' + fileTokenMatch[1]
+ ===
+ newStreamName + '/' + newName) {
+ ok = false;
+ }
+ }
+ }
+ suffixInt = (suffixInt || 0) + 1;
}
return newName;
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list