Permalink
Browse files

+ Holy cow levels of optimization from presidentbeef. I write slow ba…

…d code.

[git-p4: depot-paths = "//src/ruby_parser/dev/": change = 11774]
  • Loading branch information...
zenspider committed Nov 27, 2018
1 parent dd2adec commit 358e5a058e1eca75c6d6ab075ae31c2cc44827a5
Showing with 10 additions and 4 deletions.
  1. +2 −1 lib/ruby_lexer.rb
  2. +5 −1 lib/ruby_parser.rb
  3. +3 −2 lib/ruby_parser_extras.rb
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8

$DEBUG = true if ENV["DEBUG"]
@@ -947,7 +948,7 @@ def read_escape # TODO: remove / rewrite
rb_compile_error("Invalid escape character syntax")
else
ss.getch
end
end.dup
end

def regx_options # TODO: rewrite / remove
@@ -16,8 +16,12 @@ def self.inherited x
RubyParser::VERSIONS << x
end

def self.version= v
@version = v
end

def self.version
Parser > self and self.name[/(?:V|Ruby)(\d+)/, 1].to_i
@version ||= Parser > self && self.name[/(?:V|Ruby)(\d+)/, 1].to_i
end
end

@@ -1012,7 +1012,7 @@ def handle_encoding str
has_enc = str.respond_to? :encoding
encoding = nil

header = str.lines.first(2)
header = str.each_line.first(2)
header.map! { |s| s.force_encoding "ASCII-8BIT" } if has_enc

first = header.first || ""
@@ -1358,9 +1358,10 @@ def pop

def push val
@stack.push val
return unless debug
c = caller.first
c = caller[1] if c =~ /expr_result/
warn "#{name}_stack(push): #{val} at line #{c.clean_caller}" if debug
warn "#{name}_stack(push): #{val} at line #{c.clean_caller}"
nil
end

0 comments on commit 358e5a0

Please sign in to comment.