Skip to content

Commit d77a849

Browse files
committed
Tidy up code in RegexpNodes
1 parent f3e8b62 commit d77a849

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

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

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -105,41 +105,18 @@ public static Encoding checkEncoding(DynamicObject regexp, Rope str, boolean war
105105
return checkEncoding(regexp, str.getEncoding(), str.getCodeRange(), warn);
106106
}
107107

108-
// TODO (nirvdrum 03-June-15) Unify with JRuby in RegexpSupport.
109108
public static Encoding checkEncoding(DynamicObject regexp, Encoding strEnc, CodeRange codeRange, boolean warn) {
110109
assert RubyGuards.isRubyRegexp(regexp);
111110

112111
final Encoding regexEnc = Layouts.REGEXP.getRegex(regexp).getEncoding();
113112

114-
/*
115-
if (str.scanForCodeRange() == StringSupport.CR_BROKEN) {
116-
throw getRuntime().newArgumentError("invalid byte sequence in " + str.getEncoding());
117-
}
118-
*/
119-
//check();
120113
if (strEnc == regexEnc) {
121114
return regexEnc;
122115
} else if (regexEnc == USASCIIEncoding.INSTANCE && codeRange == CodeRange.CR_7BIT) {
123116
return regexEnc;
124-
} else if (!strEnc.isAsciiCompatible()) {
125-
if (strEnc != regexEnc) {
126-
//encodingMatchError(getRuntime(), pattern, enc);
127-
}
128-
} else if (Layouts.REGEXP.getOptions(regexp).isFixed()) {
129-
/*
130-
if (enc != pattern.getEncoding() &&
131-
(!pattern.getEncoding().isAsciiCompatible() ||
132-
str.scanForCodeRange() != StringSupport.CR_7BIT)) {
133-
encodingMatchError(getRuntime(), pattern, enc);
134-
}
135-
*/
117+
} else if (strEnc.isAsciiCompatible() && Layouts.REGEXP.getOptions(regexp).isFixed()) {
136118
return regexEnc;
137119
}
138-
/*
139-
if (warn && this.options.isEncodingNone() && enc != ASCIIEncoding.INSTANCE && str.scanForCodeRange() != StringSupport.CR_7BIT) {
140-
getRuntime().getWarnings().warn(ID.REGEXP_MATCH_AGAINST_STRING, "regexp match /.../n against to " + enc + " string");
141-
}
142-
*/
143120
return strEnc;
144121
}
145122

@@ -198,7 +175,7 @@ public abstract static class MatchStartNode extends CoreMethodArrayArgumentsNode
198175
@Child private RopeNodes.BytesNode bytesNode = RopeNodes.BytesNode.create();
199176

200177
@Specialization(guards = "isRubyString(string)")
201-
public Object matchStart(VirtualFrame frame, DynamicObject regexp, DynamicObject string, int startPos) {
178+
public Object matchStart(DynamicObject regexp, DynamicObject string, int startPos) {
202179
final Rope rope = StringOperations.rope(string);
203180
final Matcher matcher = createMatcher(getContext(), regexp, rope, bytesNode.execute(rope), true);
204181
int range = rope.byteLength();
@@ -255,7 +232,7 @@ public abstract static class SearchFromNode extends CoreMethodArrayArgumentsNode
255232
@Child private RopeNodes.BytesNode bytesNode = RopeNodes.BytesNode.create();
256233

257234
@Specialization(guards = "isRubyString(string)")
258-
public Object searchFrom(VirtualFrame frame, DynamicObject regexp, DynamicObject string, int startPos) {
235+
public Object searchFrom(DynamicObject regexp, DynamicObject string, int startPos) {
259236
final Rope rope = StringOperations.rope(string);
260237
final Matcher matcher = createMatcher(getContext(), regexp, rope, bytesNode.execute(rope), true);
261238
int range = StringOperations.rope(string).byteLength();
@@ -271,7 +248,7 @@ public abstract static class SearchFromBinaryNode extends CoreMethodArrayArgumen
271248
@Child private RopeNodes.BytesNode bytesNode = RopeNodes.BytesNode.create();
272249

273250
@Specialization(guards = "isRubyString(string)")
274-
public Object searchFrom(VirtualFrame frame, DynamicObject regexp, DynamicObject string, int startPos) {
251+
public Object searchFrom(DynamicObject regexp, DynamicObject string, int startPos) {
275252
final Rope rope = StringOperations.rope(string);
276253
final Matcher matcher = createMatcher(getContext(), regexp, rope, bytesNode.execute(rope), false);
277254
final int endPos = rope.byteLength();

0 commit comments

Comments
 (0)