From d6f4bded25ee0b8f1216b806bf37c0d11e6b3e79 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Thu, 23 Apr 2015 20:14:46 +1000 Subject: [PATCH] Memoize PHP compatibility info Summary: Ref T7892. Avoid reading the PHP compatibility information for every file being linted. Test Plan: ```name=Before real 1m24.327s user 1m19.571s sys 0m5.239s ``` ```lang=After real 1m12.029s user 1m5.756s sys 0m5.502s ``` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T7892 Differential Revision: https://secure.phabricator.com/D12518 --- src/lint/linter/ArcanistXHPASTLinter.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php index 7b95511f..6a06039a 100644 --- a/src/lint/linter/ArcanistXHPASTLinter.php +++ b/src/lint/linter/ArcanistXHPASTLinter.php @@ -500,13 +500,17 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter { } private function lintPHPCompatibility(XHPASTNode $root) { + static $compat_info; + if (!$this->version) { return; } - $target = phutil_get_library_root('phutil'). - '/../resources/php_compat_info.json'; - $compat_info = phutil_json_decode(Filesystem::readFile($target)); + if ($compat_info === null) { + $target = phutil_get_library_root('phutil'). + '/../resources/php_compat_info.json'; + $compat_info = phutil_json_decode(Filesystem::readFile($target)); + } // Create a whitelist for symbols which are being used conditionally. $whitelist = array(