Skip to content

Commit

Permalink
Optimize ParameterName
Browse files Browse the repository at this point in the history
Don't re-tokenize the arguments unless their source text contains
something that looks like a parameter comment.

RELNOTES: N/A

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170149858
  • Loading branch information
cushon committed Sep 28, 2017
1 parent 606866c commit b639ff7
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -85,10 +85,13 @@ private void checkArguments(
}
int start = ((JCTree) tree).getStartPosition();
int end = state.getEndPosition(getLast(arguments));
String source = state.getSourceCode().subSequence(start, end).toString();
if (!NamedParameterComment.PARAMETER_COMMENT_PATTERN.matcher(source).find()) {
// fast path if the arguments don't contain anything that looks like a parameter comment
return;
}
Deque<ErrorProneToken> tokens =
new ArrayDeque<>(
ErrorProneTokens.getTokens(
state.getSourceCode().subSequence(start, end).toString(), state.context));
new ArrayDeque<>(ErrorProneTokens.getTokens(source, state.context));
forEachPair(
sym.getParameters().stream(),
arguments.stream(),
Expand Down

0 comments on commit b639ff7

Please sign in to comment.