mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Improve performance of XHPASTLinter
Summary: - XHPASTLinter + coverage is ass-slow. - Use caching/perf options introduced by D1828. Test Plan: - Ran profiling for unit tests with new --xprofile command line flag. - Old profile: https://secure.phabricator.com/xhprof/profile/PHID-FILE-uiuwsqa5wulj7eyfkjy2/ - New profile: https://secure.phabricator.com/xhprof/profile/PHID-FILE-nl635t3jcp2sfo2spzwu/ - Overall runtime decreased from 18.2s to 3.7s (4.9x performance increase) with coverage enabled. Reviewers: btrahan Reviewed By: btrahan CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1829
This commit is contained in:
parent
92febf184e
commit
8088b4cdac
1 changed files with 23 additions and 24 deletions
|
@ -164,6 +164,9 @@ final class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
|
||||
$root = $this->trees[$path]->getRootNode();
|
||||
|
||||
$root->buildSelectCache();
|
||||
$root->buildTokenCache();
|
||||
|
||||
$this->lintUseOfThisInStaticMethods($root);
|
||||
$this->lintDynamicDefines($root);
|
||||
$this->lintSurpriseConstructors($root);
|
||||
|
@ -406,19 +409,18 @@ final class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
|
||||
|
||||
protected function lintHashComments($root) {
|
||||
$tokens = $root->getTokens();
|
||||
foreach ($tokens as $token) {
|
||||
if ($token->getTypeName() == 'T_COMMENT') {
|
||||
$value = $token->getValue();
|
||||
if ($value[0] == '#') {
|
||||
$this->raiseLintAtOffset(
|
||||
$token->getOffset(),
|
||||
self::LINT_COMMENT_STYLE,
|
||||
'Use "//" single-line comments, not "#".',
|
||||
'#',
|
||||
'//');
|
||||
}
|
||||
foreach ($root->selectTokensOfType('T_COMMENT') as $comment) {
|
||||
$value = $comment->getValue();
|
||||
if ($value[0] != '#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->raiseLintAtOffset(
|
||||
$comment->getOffset(),
|
||||
self::LINT_COMMENT_STYLE,
|
||||
'Use "//" single-line comments, not "#".',
|
||||
'#',
|
||||
'//');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -788,13 +790,12 @@ final class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
break;
|
||||
}
|
||||
}
|
||||
foreach ($tokens as $token) {
|
||||
if ($token->getTypeName() == 'T_CLOSE_TAG') {
|
||||
$this->raiseLintAtToken(
|
||||
$token,
|
||||
self::LINT_PHP_CLOSE_TAG,
|
||||
'Do not use the PHP closing tag, "?>".');
|
||||
}
|
||||
|
||||
foreach ($root->selectTokensOfType('T_CLOSE_TAG') as $token) {
|
||||
$this->raiseLintAtToken(
|
||||
$token,
|
||||
self::LINT_PHP_CLOSE_TAG,
|
||||
'Do not use the PHP closing tag, "?>".');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1341,12 +1342,10 @@ final class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
}
|
||||
|
||||
protected function lintTODOComments($root) {
|
||||
$tokens = $root->getTokens();
|
||||
foreach ($tokens as $token) {
|
||||
if (!$token->isComment()) {
|
||||
continue;
|
||||
}
|
||||
$comments = $root->selectTokensOfType('T_COMMENT') +
|
||||
$root->selectTokensOfType('T_DOC_COMMENT');
|
||||
|
||||
foreach ($comments as $token) {
|
||||
$value = $token->getValue();
|
||||
$matches = null;
|
||||
$preg = preg_match_all(
|
||||
|
|
Loading…
Reference in a new issue