Skip to content

Commit 43a913c

Browse files
committed
Use an uncached HashStoreLibrary for assertions
1 parent 4f76515 commit 43a913c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/main/java/org/truffleruby/core/hash/library/HashStoreLibrary.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ public static HashStoreLibrary createDispatched() {
4747
return FACTORY.createDispatched(HashGuards.hashStrategyLimit());
4848
}
4949

50+
public static HashStoreLibrary createUncached(RubyHash hash) {
51+
final Object store = hash.store;
52+
return FACTORY.getUncached(store);
53+
}
54+
5055
public static boolean verify(RubyHash hash) {
5156
final Object store = hash.store;
52-
return FACTORY.getUncached(store).verify(store, hash);
57+
return createUncached(hash).verify(store, hash);
5358
}
5459

5560
/** Looks up the key in the hash and returns the associated value, or the result of calling {@code defaultNode} if

src/main/java/org/truffleruby/language/arguments/ReadUserKeywordsHashNode.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
public final class ReadUserKeywordsHashNode extends RubyBaseNode {
2121

22-
@Child protected HashStoreLibrary hashStoreLibrary;
23-
2422
private final ConditionProfile keywordArgumentsProfile = ConditionProfile.create();
2523

2624
public RubyHash execute(VirtualFrame frame) {
@@ -37,15 +35,13 @@ public RubyHash execute(VirtualFrame frame) {
3735

3836
/** Verify that all keywords the descriptor claims should be in the hash, are in fact in the hash. **/
3937
private boolean assertHashMatchesDescriptor(RubyHash hash, KeywordArgumentsDescriptor descriptor) {
40-
if (hashStoreLibrary == null) {
41-
hashStoreLibrary = insert(HashStoreLibrary.createDispatched());
42-
}
38+
final HashStoreLibrary hashStoreLibrary = HashStoreLibrary.createUncached(hash);
4339

4440
for (String keyword : descriptor.getKeywords()) {
4541
final RubySymbol symbol = getSymbol(keyword);
4642
final Object value = hashStoreLibrary.lookupOrDefault(hash.store, null, hash, symbol, (f, h, k) -> null);
4743
assert value != null : "descriptor claims " + keyword +
48-
" was a passed keyword argument but it's not in the hash";
44+
" was a passed as a keyword argument but it's not in the hash";
4945
}
5046
return true;
5147
}

0 commit comments

Comments
 (0)