add comments to explain perf sensitive code

pull/5584/head
halfnelson 5 years ago
parent 21f73389ff
commit b07e99c351

@ -149,16 +149,16 @@ export default async function preprocess(
filename filename
}); });
if (processed) { if (!processed) continue;
if (processed.dependencies) dependencies.push(...processed.dependencies);
source = processed.code; if (processed.dependencies) dependencies.push(...processed.dependencies);
if (processed.map) { source = processed.code;
sourcemap_list.unshift( if (processed.map) {
typeof(processed.map) === 'string' sourcemap_list.unshift(
? JSON.parse(processed.map) typeof(processed.map) === 'string'
: processed.map ? JSON.parse(processed.map)
); : processed.map
} );
} }
} }

@ -59,6 +59,8 @@ function merge_tables<T>(this_table: T[], other_table: T[]): [T[], number[], boo
} }
function pushArray<T>(_this: T[], other: T[]) { function pushArray<T>(_this: T[], other: T[]) {
// We use push to mutate in place for memory and perf reasons
// We use the for loop instead of _this.push(...other) to avoid the JS engine's function argument limit (65,535 in JavascriptCore)
for (let i = 0; i < other.length; i++) { for (let i = 0; i < other.length; i++) {
_this.push(other[i]); _this.push(other[i]);
} }

Loading…
Cancel
Save