Improve performance of JSDoc tag utilities#16836
Merged
3 commits merged intoJul 10, 2017
Merged
Conversation
yuit
reviewed
Jul 5, 2017
| export function getJSDocTags(node: Node): JSDocTag[] | undefined { | ||
| const cache = node.jsDocCache; | ||
| switch (cache) { | ||
| case null: // tslint:disable-line no-null-keyword |
Contributor
There was a problem hiding this comment.
Could you make comment what it means for null and undefined?
| return result; | ||
|
|
||
| function getJSDocsWorker(node: Node) { | ||
| function work(node: Node) { |
Contributor
There was a problem hiding this comment.
nit: this is a bit inconsistent with how we name helper function in the codebase... I would prefer getJSDocCommentsAndTagsWorker
|
|
||
| function getFirstJSDocTag(node: Node, kind: SyntaxKind): JSDocTag { | ||
| return node && firstOrUndefined(getJSDocTags(node, kind)); | ||
| function getFirstJSDocTag(node: Node, kind: SyntaxKind) { |
| return map(getJSDocs(node), doc => doc.comment); | ||
| } | ||
|
|
||
| export function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration) { |
| } | ||
|
|
||
| export function getJSDocs(node: Node): (JSDoc | JSDocTag)[] { | ||
| export function getAllJSDocs(node: Node): Array<JSDoc | JSDocTag> | undefined { |
Contributor
There was a problem hiding this comment.
Q: why did we use Array<JSDoc | JSDocTag> instead (JSDoc | JSDocTag)[] ?
| if (!cache) { | ||
| getJSDocsWorker(node); | ||
| node.jsDocCache = cache; | ||
| export function getJSDocTags(node: Node): JSDocTag[] | undefined { |
Contributor
There was a problem hiding this comment.
Q: why this function get export?
Author
There was a problem hiding this comment.
It's needed in getJsDocTagsFromDeclarations in jsDoc.ts.
yuit
approved these changes
Jul 10, 2017
gcnew
added a commit
to gcnew/TypeScript
that referenced
this pull request
Jul 10, 2017
This reverts commit bffde58.
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We currently have no good performance regression tests of large
--checkJsprojects, since it's a new feature. Previously the process for something likegetJSDocReturnTaglooked like this:undefined, either it's not in the cache yet, or we already tried getting jsdoc tags and there were none.firstOrUndefinedof that.This changes it to:
null, then we've already determined that this node has no jsdoc tags.undefined, iterate and get tags as before.JSDocReturnTag.