Skip to content

Commit 05d8669

Browse files
wildmaplesnirvdrum
authored andcommitted
Inline createMatcher and simply code because encodingConversion is always true
1 parent a2dcde6 commit 05d8669

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

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

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,6 @@
7575
@CoreModule("Truffle::RegexpOperations")
7676
public class TruffleRegexpNodes {
7777

78-
public static Matcher createMatcher(RubyContext context, RubyRegexp regexp, Rope stringRope, byte[] stringBytes,
79-
boolean encodingConversion, int start, Node currentNode) {
80-
final Encoding enc = checkEncoding(regexp, stringRope.getEncoding(), stringRope.getCodeRange());
81-
Regex regex = regexp.regex;
82-
83-
if (encodingConversion && regex.getEncoding() != enc) {
84-
EncodingCache encodingCache = regexp.cachedEncodings;
85-
regex = encodingCache.getOrCreate(enc, e -> makeRegexpForEncoding(context, regexp, e, currentNode));
86-
}
87-
88-
return getMatcher(regex, stringBytes, start);
89-
}
90-
9178
public static Encoding checkEncoding(RubyRegexp regexp, Encoding strEnc, CodeRange codeRange) {
9279
final Encoding regexEnc = regexp.regex.getEncoding();
9380

@@ -397,14 +384,15 @@ protected Object matchInRegion(
397384
@Cached TruffleRegexpNodes.MatchNode matchNode,
398385
@CachedLibrary(limit = "2") RubyStringLibrary libString) {
399386
Rope rope = libString.getRope(string);
400-
Matcher matcher = createMatcher(
401-
getContext(),
402-
regexp,
403-
rope,
404-
bytesNode.execute(rope),
405-
encodingConversion,
406-
startPos,
407-
this);
387+
final Encoding enc = checkEncoding(regexp, rope.getEncoding(), rope.getCodeRange());
388+
Regex regex = regexp.regex;
389+
390+
if (regex.getEncoding() != enc) {
391+
EncodingCache encodingCache = regexp.cachedEncodings;
392+
regex = encodingCache.getOrCreate(enc, e -> makeRegexpForEncoding(getContext(), regexp, e, this));
393+
}
394+
395+
Matcher matcher = getMatcher(regex, bytesNode.execute(rope), startPos);
408396
return matchNode.execute(regexp, string, matcher, fromPos, toPos, atStart);
409397
}
410398
}

0 commit comments

Comments
 (0)