Skip to content

Commit

Permalink
Remove some dead code.
Browse files Browse the repository at this point in the history
Add tiny optimization where we will not try to look past first seen token for
magic comments unless we happen to be running with -w.
enebo committed Jan 22, 2018
1 parent 28db22d commit 065f144
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 0 additions & 6 deletions core/src/main/java/org/jruby/lexer/LexingCommon.java
Original file line number Diff line number Diff line change
@@ -818,9 +818,6 @@ public static int magicCommentMarker(ByteList str, int begin) {
return -1;
}

public static final String magicString = "^[^\\S]*([^\\s\'\":;]+)\\s*:\\s*(\"(?:\\\\.|[^\"])*\"|[^\"\\s;]+)[\\s;]*[^\\S]*$";
public static final Regex magicRegexp = new Regex(magicString.getBytes(), 0, magicString.length(), 0, Encoding.load("ASCII"));

public boolean parser_magic_comment(ByteList magicLine) {
boolean indicator = false;
int vbeg, vend;
@@ -840,9 +837,6 @@ public boolean parser_magic_comment(ByteList magicLine) {

/* %r"([^\\s\'\":;]+)\\s*:\\s*(\"(?:\\\\.|[^\"])*\"|[^\"\\s;]+)[\\s;]*" */
while (length > 0) {
int i;
long n = 0;

for (; length > 0; str++, --length) {
char c = magicLine.charAt(str);

6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/lexer/yacc/RubyLexer.java
Original file line number Diff line number Diff line change
@@ -874,8 +874,10 @@ private int yylex() throws IOException {
continue;
case '#': { /* it's a comment */
this.tokenSeen = tokenSeen;
if (!parser_magic_comment(lexb.makeShared(lex_p, lex_pend - lex_p))) {
if (comment_at_top()) set_file_encoding(lex_p, lex_pend);
if (!tokenSeen || !warnings.isVerbose()) {
if (!parser_magic_comment(lexb.makeShared(lex_p, lex_pend - lex_p))) {
if (comment_at_top()) set_file_encoding(lex_p, lex_pend);
}
}
lex_p = lex_pend;
}

0 comments on commit 065f144

Please sign in to comment.