Skip to content

Commit 61e842c

Browse files
committed
Check if TRegex supports the encoding first as this is very fast
* Does not matter currently as all callers already check the encoding before, but that could change.
1 parent 9eff829 commit 61e842c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ public static String toTRegexEncoding(RubyEncoding encoding) {
137137

138138
@TruffleBoundary
139139
private static Object compileTRegex(RubyContext context, RubyRegexp regexp, boolean atStart, RubyEncoding enc) {
140+
String tRegexEncoding = TRegexCache.toTRegexEncoding(enc);
141+
if (tRegexEncoding == null) {
142+
return null;
143+
}
144+
140145
String processedRegexpSource;
141146
RubyEncoding[] fixedEnc = new RubyEncoding[]{ null };
142147
final TStringBuilder tstringBuilder;
@@ -163,11 +168,6 @@ private static Object compileTRegex(RubyContext context, RubyRegexp regexp, bool
163168

164169
String flags = optionsToFlags(regexp.options, atStart);
165170

166-
String tRegexEncoding = TRegexCache.toTRegexEncoding(enc);
167-
if (tRegexEncoding == null) {
168-
return null;
169-
}
170-
171171
String ignoreAtomicGroups = context.getOptions().TRUFFLE_REGEX_IGNORE_ATOMIC_GROUPS
172172
? ",IgnoreAtomicGroups=true"
173173
: "";

0 commit comments

Comments
 (0)