Merge branch 'transforms-fixPerformance' into transforms-visitEachChildPerf

This commit is contained in:
Ron Buckton
2016-05-26 22:15:22 -07:00
11 changed files with 75 additions and 215 deletions

View File

@@ -82,12 +82,9 @@ namespace ts {
function getLeadingComments(range: TextRange): CommentRange[];
function getLeadingComments(range: TextRange, contextNode: Node, ignoreNodeCallback: (contextNode: Node) => boolean, getTextRangeCallback: (contextNode: Node) => TextRange): CommentRange[];
function getLeadingComments(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (contextNode: Node) => boolean, getTextRangeCallback?: (contextNode: Node) => TextRange) {
let comments: CommentRange[] = [];
let ignored = false;
if (contextNode) {
range = getTextRangeCallback(contextNode) || range;
if (ignoreNodeCallback(contextNode)) {
ignored = true;
// If the node will not be emitted in JS, remove all the comments (normal,
// pinned and `///`) associated with the node, unless it is a triple slash
// comment at the top of the file.
@@ -101,16 +98,14 @@ namespace ts {
// The first `///` will NOT be removed while the second one will be removed
// even though both nodes will not be emitted.
if (range.pos === 0) {
comments = filter(getLeadingCommentsOfPosition(0), isTripleSlashComment);
return filter(getLeadingCommentsOfPosition(0), isTripleSlashComment);
}
return;
}
}
if (!ignored) {
comments = getLeadingCommentsOfPosition(range.pos);
}
return comments;
return getLeadingCommentsOfPosition(range.pos);
}
/**
@@ -277,42 +272,42 @@ namespace ts {
reset,
setSourceFile,
getLeadingComments(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (contextNode: Node) => boolean, getTextRangeCallback?: (contextNode: Node) => TextRange): CommentRange[] {
performance.mark("commentStart");
const commentStart = performance.mark();
const comments = getLeadingComments(range, contextNode, ignoreNodeCallback, getTextRangeCallback);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
return comments;
},
getTrailingComments(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (contextNode: Node) => boolean, getTextRangeCallback?: (contextNode: Node) => TextRange): CommentRange[] {
performance.mark("commentStart");
const commentStart = performance.mark();
const comments = getTrailingComments(range, contextNode, ignoreNodeCallback, getTextRangeCallback);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
return comments;
},
getTrailingCommentsOfPosition(pos: number): CommentRange[] {
performance.mark("commentStart");
const commentStart = performance.mark();
const comments = getTrailingCommentsOfPosition(pos);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
return comments;
},
emitLeadingComments(range: TextRange, comments: CommentRange[], contextNode?: Node, getTextRangeCallback?: (contextNode: Node) => TextRange): void {
performance.mark("commentStart");
const commentStart = performance.mark();
emitLeadingComments(range, comments, contextNode, getTextRangeCallback);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
},
emitTrailingComments(range: TextRange, comments: CommentRange[]): void {
performance.mark("commentStart");
const commentStart = performance.mark();
emitLeadingComments(range, comments);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
},
emitLeadingDetachedComments(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (contextNode: Node) => boolean): void {
performance.mark("commentStart");
const commentStart = performance.mark();
emitLeadingDetachedComments(range, contextNode, ignoreNodeCallback);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
},
emitTrailingDetachedComments(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (contextNode: Node) => boolean): void {
performance.mark("commentStart");
const commentStart = performance.mark();
emitTrailingDetachedComments(range, contextNode, ignoreNodeCallback);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
}
};
}