Skip to content

Commit e7b1cba

Browse files
committed
Simplify ToHashByHashCode
(cherry picked from commit 9ed5948)
1 parent 309b411 commit e7b1cba

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/main/java/org/truffleruby/core/hash/HashingNodes.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import com.oracle.truffle.api.dsl.Cached;
1313
import com.oracle.truffle.api.dsl.CachedContext;
14+
import com.oracle.truffle.api.dsl.Fallback;
1415
import com.oracle.truffle.api.dsl.GenerateUncached;
1516
import com.oracle.truffle.api.dsl.Specialization;
1617
import org.truffleruby.RubyContext;
@@ -25,7 +26,6 @@
2526
import org.truffleruby.core.symbol.SymbolNodes;
2627
import org.truffleruby.core.string.ImmutableRubyString;
2728
import org.truffleruby.language.RubyBaseNode;
28-
import org.truffleruby.language.RubyGuards;
2929
import org.truffleruby.language.dispatch.DispatchNode;
3030

3131
public abstract class HashingNodes {
@@ -109,24 +109,18 @@ protected int hashImmutableString(ImmutableRubyString value,
109109
return (int) stringHashNode.execute(value);
110110
}
111111

112-
113112
@Specialization
114113
protected int hashSymbol(RubySymbol value,
115114
@Cached SymbolNodes.HashSymbolNode symbolHashNode) {
116115
return (int) symbolHashNode.execute(value);
117116
}
118117

119-
@Specialization(guards = "!isSpecialized(value)")
118+
@Fallback
120119
protected int hash(Object value,
121120
@Cached DispatchNode callHash,
122121
@Cached HashCastResultNode cast) {
123122
return cast.execute(callHash.call(value, "hash"));
124123
}
125-
126-
protected static boolean isSpecialized(Object value) {
127-
return RubyGuards.isPrimitive(value) || value instanceof RubyBignum || value instanceof RubyString ||
128-
value instanceof ImmutableRubyString || value instanceof RubySymbol;
129-
}
130124
}
131125

132126
@GenerateUncached

0 commit comments

Comments
 (0)