15
15
import org .truffleruby .core .string .ImmutableRubyString ;
16
16
import org .truffleruby .language .RubyBaseNode ;
17
17
import org .truffleruby .language .dispatch .DispatchNode ;
18
- import org .truffleruby .language .library .RubyLibrary ;
19
18
20
19
import com .oracle .truffle .api .dsl .Specialization ;
21
- import com .oracle .truffle .api .library .CachedLibrary ;
22
20
23
21
@ GenerateUncached
24
22
public abstract class FreezeHashKeyIfNeededNode extends RubyBaseNode {
@@ -30,31 +28,21 @@ protected Object immutable(ImmutableRubyString string, boolean compareByIdentity
30
28
return string ;
31
29
}
32
30
33
- @ Specialization (
34
- guards = "rubyLibrary.isFrozen(string)" ,
35
- limit = "getRubyLibraryCacheLimit()" )
36
- protected Object alreadyFrozen (RubyString string , boolean compareByIdentity ,
37
- @ CachedLibrary ("string" ) RubyLibrary rubyLibrary ) {
31
+ @ Specialization (guards = "string.isFrozen()" )
32
+ protected Object alreadyFrozen (RubyString string , boolean compareByIdentity ) {
38
33
return string ;
39
34
}
40
35
41
- @ Specialization (
42
- guards = { "!rubyLibrary.isFrozen(string)" , "!compareByIdentity" },
43
- limit = "getRubyLibraryCacheLimit()" )
36
+ @ Specialization (guards = { "!string.isFrozen()" , "!compareByIdentity" })
44
37
protected Object dupAndFreeze (RubyString string , boolean compareByIdentity ,
45
- @ CachedLibrary ("string" ) RubyLibrary rubyLibrary ,
46
- @ CachedLibrary (limit = "getRubyLibraryCacheLimit()" ) RubyLibrary rubyLibraryObject ,
47
38
@ Cached DispatchNode dupNode ) {
48
- final Object object = dupNode .call (string , "dup" );
49
- rubyLibraryObject .freeze (object );
50
- return object ;
39
+ final RubyString copy = ( RubyString ) dupNode .call (string , "dup" );
40
+ copy .freeze ();
41
+ return copy ;
51
42
}
52
43
53
- @ Specialization (
54
- guards = { "!rubyLibrary.isFrozen(string)" , "compareByIdentity" },
55
- limit = "getRubyLibraryCacheLimit()" )
56
- protected Object compareByIdentity (RubyString string , boolean compareByIdentity ,
57
- @ CachedLibrary ("string" ) RubyLibrary rubyLibrary ) {
44
+ @ Specialization (guards = { "!string.isFrozen()" , "compareByIdentity" })
45
+ protected Object compareByIdentity (RubyString string , boolean compareByIdentity ) {
58
46
return string ;
59
47
}
60
48
0 commit comments