From 371cb242b7a910a45f4a3fed3599d6c4f9c1d25b Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Tue, 26 Mar 2019 13:49:03 -0700 Subject: [PATCH] Replace static variables with __MemoizeLSB --- .hhconfig | 1 + .travis.sh | 5 ++++- composer.lock | 22 +++++++++++----------- src/core/ComposableElement.php | 30 +++++++++++------------------- 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/.hhconfig b/.hhconfig index 5e3b4da2..e098c907 100644 --- a/.hhconfig +++ b/.hhconfig @@ -6,4 +6,5 @@ disallow_unsafe_comparisons=true decl_override_require_hint=true enable_experimental_tc_features=shape_field_check,sealed_classes user_attributes= +disable_static_local_variables = true disable_primitive_refinement=true diff --git a/.travis.sh b/.travis.sh index c11e4303..648bbb57 100755 --- a/.travis.sh +++ b/.travis.sh @@ -9,7 +9,10 @@ php --version cd $(mktemp -d) curl https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer ) +if (hhvm --version | grep -q -- -dev); then + rm composer.lock +fi composer install hh_client -hhvm vendor/bin/hacktest tests/ +vendor/bin/hacktest tests/ diff --git a/composer.lock b/composer.lock index 02949ae7..e8fe6d7a 100644 --- a/composer.lock +++ b/composer.lock @@ -153,16 +153,16 @@ }, { "name": "facebook/hh-clilib", - "version": "v2.1.0", + "version": "v2.1.1", "source": { "type": "git", "url": "https://github.com/hhvm/hh-clilib.git", - "reference": "44f30c1f07b9d36430bfff721a119a0d43b15edd" + "reference": "9d6b1a8686951da24ab68ffeba25ae85d1788408" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hhvm/hh-clilib/zipball/44f30c1f07b9d36430bfff721a119a0d43b15edd", - "reference": "44f30c1f07b9d36430bfff721a119a0d43b15edd", + "url": "https://api.github.com/repos/hhvm/hh-clilib/zipball/9d6b1a8686951da24ab68ffeba25ae85d1788408", + "reference": "9d6b1a8686951da24ab68ffeba25ae85d1788408", "shasum": "" }, "require": { @@ -173,7 +173,7 @@ "require-dev": { "facebook/fbexpect": "^2.1.0", "hhvm/hacktest": "^1.0.0", - "hhvm/hhast": "^4.0" + "hhvm/hhast": "^4.0.2" }, "type": "library", "extra": { @@ -185,7 +185,7 @@ "license": [ "MIT" ], - "time": "2019-02-12T20:14:07+00:00" + "time": "2019-03-26T18:31:27+00:00" }, { "name": "hhvm/hacktest", @@ -230,16 +230,16 @@ }, { "name": "hhvm/hhvm-autoload", - "version": "v2.0.5", + "version": "v2.0.6", "source": { "type": "git", "url": "https://github.com/hhvm/hhvm-autoload.git", - "reference": "dbd50d7fb1856d1f6757e10bc30eb2bf5d17b3f1" + "reference": "4f510960e71adcad661c33ae355d0d9670d9c805" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hhvm/hhvm-autoload/zipball/dbd50d7fb1856d1f6757e10bc30eb2bf5d17b3f1", - "reference": "dbd50d7fb1856d1f6757e10bc30eb2bf5d17b3f1", + "url": "https://api.github.com/repos/hhvm/hhvm-autoload/zipball/4f510960e71adcad661c33ae355d0d9670d9c805", + "reference": "4f510960e71adcad661c33ae355d0d9670d9c805", "shasum": "" }, "require": { @@ -273,7 +273,7 @@ ] }, "notification-url": "https://packagist.org/downloads/", - "time": "2019-03-22T21:27:20+00:00" + "time": "2019-03-26T17:57:44+00:00" }, { "name": "hhvm/hsl-experimental", diff --git a/src/core/ComposableElement.php b/src/core/ComposableElement.php index 3cdcb08c..47483b94 100644 --- a/src/core/ComposableElement.php +++ b/src/core/ComposableElement.php @@ -259,32 +259,24 @@ final public static function __xhpReflectionAttribute( return null; } + <<__MemoizeLSB>> final public static function __xhpReflectionAttributes( ): Map { - static $cache = Map {}; - $class = static::class; - if (!$cache->containsKey($class)) { - $map = Map {}; - $decl = static::__xhpAttributeDeclaration(); - foreach ($decl as $name => $attr_decl) { - $map[$name] = new ReflectionXHPAttribute($name, $attr_decl); - } - $cache[$class] = $map; + $map = Map {}; + $decl = static::__xhpAttributeDeclaration(); + foreach ($decl as $name => $attr_decl) { + $map[$name] = new ReflectionXHPAttribute($name, $attr_decl); } - return $cache[$class]; + return $map; } + <<__MemoizeLSB>> final public static function __xhpReflectionChildrenDeclaration( ): ReflectionXHPChildrenDeclaration { - static $cache = Map {}; - $class = static::class; - if (!$cache->containsKey($class)) { - $cache[$class] = new ReflectionXHPChildrenDeclaration( - :xhp::class2element($class), - self::emptyInstance()->__xhpChildrenDeclaration(), - ); - } - return $cache[$class]; + return new ReflectionXHPChildrenDeclaration( + :xhp::class2element(static::class), + self::emptyInstance()->__xhpChildrenDeclaration(), + ); } final public static function __xhpReflectionCategoryDeclaration(