Skip to content

Commit bdeb423

Browse files
committed
Simplify
1 parent f96504a commit bdeb423

File tree

3 files changed

+60
-116
lines changed

3 files changed

+60
-116
lines changed

src/main/java/org/truffleruby/core/kernel/KernelNodes.java

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -651,15 +651,13 @@ protected Object cloneSymbol(RubySymbol symbol, boolean freeze,
651651
return symbol;
652652
}
653653

654-
@Specialization(limit = "getRubyLibraryCacheLimit()")
654+
@Specialization
655655
protected RubyDynamicObject cloneImmutableRubyString(ImmutableRubyString self, boolean freeze,
656656
@Cached ConditionProfile freezeProfile,
657-
@Cached ConditionProfile isFrozenProfile,
658-
@CachedLibrary("self") RubyLibrary rubyLibrary,
659657
@CachedLibrary(limit = "getRubyLibraryCacheLimit()") RubyLibrary rubyLibraryFreeze,
660658
@Cached MakeStringNode makeStringNode) {
661659
final RubyDynamicObject newObject = makeStringNode.fromRope(self.rope);
662-
if (freezeProfile.profile(freeze) && isFrozenProfile.profile(rubyLibrary.isFrozen(self))) {
660+
if (freezeProfile.profile(freeze)) {
663661
rubyLibraryFreeze.freeze(newObject);
664662
}
665663

@@ -1021,12 +1019,7 @@ public abstract static class InitializeDupCloneNode extends CoreMethodArrayArgum
10211019
@Child private DispatchNode initializeCopyNode = DispatchNode.create();
10221020

10231021
@Specialization
1024-
protected Object initializeDup(VirtualFrame frame, RubyDynamicObject self, RubyDynamicObject from) {
1025-
return initializeCopyNode.call(self, "initialize_copy", from);
1026-
}
1027-
1028-
@Specialization
1029-
protected Object initializeDup(VirtualFrame frame, RubyDynamicObject self, ImmutableRubyString from) {
1022+
protected Object initializeDup(RubyDynamicObject self, Object from) {
10301023
return initializeCopyNode.call(self, "initialize_copy", from);
10311024
}
10321025

@@ -1685,20 +1678,7 @@ private void useCallerRefinements(VirtualFrame frame) {
16851678
public abstract static class RespondToMissingNode extends CoreMethodArrayArgumentsNode {
16861679

16871680
@Specialization
1688-
protected boolean doesRespondToMissingString(Object object, RubyString name, Object unusedIncludeAll) {
1689-
return false;
1690-
}
1691-
1692-
@Specialization
1693-
protected boolean doesRespondToMissingImmutableString(
1694-
Object object,
1695-
ImmutableRubyString name,
1696-
Object unusedIncludeAll) {
1697-
return false;
1698-
}
1699-
1700-
@Specialization
1701-
protected boolean doesRespondToMissingSymbol(Object object, RubySymbol name, Object unusedIncludeAll) {
1681+
protected boolean doesRespondToMissing(Object object, Object name, Object unusedIncludeAll) {
17021682
return false;
17031683
}
17041684

src/main/java/org/truffleruby/core/regexp/TruffleRegexpNodes.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,18 +314,17 @@ public abstract Object execute(RubyRegexp regexp, Object string, Matcher matcher
314314
//
315315
// Without a private copy, the MatchData's source could be modified to be upcased when it should remain the
316316
// same as when the MatchData was created.
317-
@Specialization(guards = "libString.isRubyString(string)")
317+
@Specialization
318318
protected Object executeMatch(
319319
RubyRegexp regexp,
320320
Object string,
321321
Matcher matcher,
322322
int startPos,
323323
int range,
324324
boolean onlyMatchAtStart,
325-
@Cached ConditionProfile matchesProfile,
326-
@CachedLibrary(limit = "2") RubyStringLibrary libString) {
325+
@Cached ConditionProfile matchesProfile) {
327326
if (getContext().getOptions().REGEXP_INSTRUMENT_MATCH) {
328-
instrument(regexp, string, libString, onlyMatchAtStart);
327+
instrument(regexp, string, onlyMatchAtStart);
329328
}
330329

331330
int match = runMatch(matcher, startPos, range, onlyMatchAtStart);
@@ -364,10 +363,9 @@ private int runMatch(Matcher matcher, int startPos, int range, boolean onlyMatch
364363
}
365364

366365
@TruffleBoundary
367-
protected void instrument(RubyRegexp regexp, Object string, RubyStringLibrary stringLibrary,
368-
boolean fromStart) {
366+
protected void instrument(RubyRegexp regexp, Object string, boolean fromStart) {
369367
Rope source = regexp.source;
370-
Encoding enc = stringLibrary.getRope(string).getEncoding();
368+
Encoding enc = RubyStringLibrary.getUncached().getRope(string).getEncoding();
371369
RegexpOptions options = regexp.options;
372370
MatchInfo matchInfo = new MatchInfo(
373371
new RegexpCacheKey(

0 commit comments

Comments
 (0)