Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Replace static variables with __MemoizeLSB
Browse files Browse the repository at this point in the history
  • Loading branch information
fredemmott committed Mar 26, 2019
1 parent 40ef973 commit 371cb24
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 31 deletions.
1 change: 1 addition & 0 deletions .hhconfig
Expand Up @@ -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
5 changes: 4 additions & 1 deletion .travis.sh
Expand Up @@ -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/
22 changes: 11 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 11 additions & 19 deletions src/core/ComposableElement.php
Expand Up @@ -259,32 +259,24 @@ final public static function __xhpReflectionAttribute(
return null;
}

<<__MemoizeLSB>>
final public static function __xhpReflectionAttributes(
): Map<string, ReflectionXHPAttribute> {
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(
Expand Down

0 comments on commit 371cb24

Please sign in to comment.