Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit 884ef00

Browse files
committed
Merge branch 'perf'
Conflicts: dist/es6-module-loader-sans-promises.min.js dist/es6-module-loader.min.js
2 parents 137c021 + beb5949 commit 884ef00

File tree

7 files changed

+93
-59
lines changed

7 files changed

+93
-59
lines changed

dist/es6-module-loader-sans-promises.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,15 @@ function logloads(loads) {
544544
// snapshot(linkSet.loader);
545545
}
546546

547+
function doLink(linkSet) {
548+
try {
549+
link(linkSet);
550+
}
551+
catch(exc) {
552+
return linkSetFailed(linkSet, exc);
553+
}
554+
}
555+
547556
// 15.2.5.2.3
548557
function updateLinkSetOnLoad(linkSet, load) {
549558
console.assert(load.status == 'loaded' || load.status == 'linked', 'loaded or linked');
@@ -579,12 +588,7 @@ function logloads(loads) {
579588
}
580589
/***/
581590

582-
try {
583-
link(linkSet);
584-
}
585-
catch(exc) {
586-
return linkSetFailed(linkSet, exc);
587-
}
591+
doLink(linkSet);
588592

589593
console.assert(linkSet.loads.length == 0, 'loads cleared');
590594

@@ -1117,20 +1121,20 @@ function logloads(loads) {
11171121
hash : m[8] || ''
11181122
} : null);
11191123
}
1124+
function removeDotSegments(input) {
1125+
var output = [];
1126+
input.replace(/^(\.\.?(\/|$))+/, '')
1127+
.replace(/\/(\.(\/|$))+/g, '/')
1128+
.replace(/\/\.\.$/, '/../')
1129+
.replace(/\/?[^\/]*/g, function (p) {
1130+
if (p === '/..')
1131+
output.pop();
1132+
else
1133+
output.push(p);
1134+
});
1135+
return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
1136+
}
11201137
function toAbsoluteURL(base, href) {
1121-
function removeDotSegments(input) {
1122-
var output = [];
1123-
input.replace(/^(\.\.?(\/|$))+/, '')
1124-
.replace(/\/(\.(\/|$))+/g, '/')
1125-
.replace(/\/\.\.$/, '/../')
1126-
.replace(/\/?[^\/]*/g, function (p) {
1127-
if (p === '/..')
1128-
output.pop();
1129-
else
1130-
output.push(p);
1131-
});
1132-
return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
1133-
}
11341138

11351139
href = parseURI(href || '');
11361140
base = parseURI(base || '');

dist/es6-module-loader-sans-promises.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6-module-loader.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,15 @@ function logloads(loads) {
12281228
// snapshot(linkSet.loader);
12291229
}
12301230

1231+
function doLink(linkSet) {
1232+
try {
1233+
link(linkSet);
1234+
}
1235+
catch(exc) {
1236+
return linkSetFailed(linkSet, exc);
1237+
}
1238+
}
1239+
12311240
// 15.2.5.2.3
12321241
function updateLinkSetOnLoad(linkSet, load) {
12331242
console.assert(load.status == 'loaded' || load.status == 'linked', 'loaded or linked');
@@ -1263,12 +1272,7 @@ function logloads(loads) {
12631272
}
12641273
/***/
12651274

1266-
try {
1267-
link(linkSet);
1268-
}
1269-
catch(exc) {
1270-
return linkSetFailed(linkSet, exc);
1271-
}
1275+
doLink(linkSet);
12721276

12731277
console.assert(linkSet.loads.length == 0, 'loads cleared');
12741278

@@ -1801,20 +1805,20 @@ function logloads(loads) {
18011805
hash : m[8] || ''
18021806
} : null);
18031807
}
1808+
function removeDotSegments(input) {
1809+
var output = [];
1810+
input.replace(/^(\.\.?(\/|$))+/, '')
1811+
.replace(/\/(\.(\/|$))+/g, '/')
1812+
.replace(/\/\.\.$/, '/../')
1813+
.replace(/\/?[^\/]*/g, function (p) {
1814+
if (p === '/..')
1815+
output.pop();
1816+
else
1817+
output.push(p);
1818+
});
1819+
return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
1820+
}
18041821
function toAbsoluteURL(base, href) {
1805-
function removeDotSegments(input) {
1806-
var output = [];
1807-
input.replace(/^(\.\.?(\/|$))+/, '')
1808-
.replace(/\/(\.(\/|$))+/g, '/')
1809-
.replace(/\/\.\.$/, '/../')
1810-
.replace(/\/?[^\/]*/g, function (p) {
1811-
if (p === '/..')
1812-
output.pop();
1813-
else
1814-
output.push(p);
1815-
});
1816-
return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
1817-
}
18181822

18191823
href = parseURI(href || '');
18201824
base = parseURI(base || '');

dist/es6-module-loader.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/loader.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,15 @@ function logloads(loads) {
544544
// snapshot(linkSet.loader);
545545
}
546546

547+
function doLink(linkSet) {
548+
try {
549+
link(linkSet);
550+
}
551+
catch(exc) {
552+
return linkSetFailed(linkSet, exc);
553+
}
554+
}
555+
547556
// 15.2.5.2.3
548557
function updateLinkSetOnLoad(linkSet, load) {
549558
console.assert(load.status == 'loaded' || load.status == 'linked', 'loaded or linked');
@@ -579,12 +588,7 @@ function logloads(loads) {
579588
}
580589
/***/
581590

582-
try {
583-
link(linkSet);
584-
}
585-
catch(exc) {
586-
return linkSetFailed(linkSet, exc);
587-
}
591+
doLink(linkSet);
588592

589593
console.assert(linkSet.loads.length == 0, 'loads cleared');
590594

lib/system.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@
3232
hash : m[8] || ''
3333
} : null);
3434
}
35+
function removeDotSegments(input) {
36+
var output = [];
37+
input.replace(/^(\.\.?(\/|$))+/, '')
38+
.replace(/\/(\.(\/|$))+/g, '/')
39+
.replace(/\/\.\.$/, '/../')
40+
.replace(/\/?[^\/]*/g, function (p) {
41+
if (p === '/..')
42+
output.pop();
43+
else
44+
output.push(p);
45+
});
46+
return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
47+
}
3548
function toAbsoluteURL(base, href) {
36-
function removeDotSegments(input) {
37-
var output = [];
38-
input.replace(/^(\.\.?(\/|$))+/, '')
39-
.replace(/\/(\.(\/|$))+/g, '/')
40-
.replace(/\/\.\.$/, '/../')
41-
.replace(/\/?[^\/]*/g, function (p) {
42-
if (p === '/..')
43-
output.pop();
44-
else
45-
output.push(p);
46-
});
47-
return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
48-
}
4949

5050
href = parseURI(href || '');
5151
base = parseURI(base || '');

test/perf.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!doctype html>
2+
<script src="../dist/es6-module-loader.js"></script>
3+
<script>
4+
System.set('module0', Module({}));
5+
System.instantiate = function(load) {
6+
return {
7+
deps: ['module1'],
8+
execute: function() {
9+
return Module({});
10+
}
11+
};
12+
}
13+
14+
function start() {
15+
var startTime = +Date.now();
16+
for (var i = 1; i <= 1000; i++)
17+
System.define('module' + i, "function() {} var p = 5; // non-trivial code");
18+
System.import('module1000').then(function() {
19+
console.log(Date.now() - startTime);
20+
});
21+
}
22+
</script>

0 commit comments

Comments
 (0)