Avoid anonymous eval

This makes it hard to track down the source of allocations
and such when profiling.
This commit is contained in:
Jean Boussier 2023-01-11 12:59:15 +01:00
parent e553b3f8a3
commit 1c1770d8b0
1 changed files with 7 additions and 10 deletions

View File

@ -103,7 +103,13 @@ module ExecJS
@popen_options[:internal_encoding] = ::Encoding.default_internal || 'UTF-8'
if @runner_path
instance_eval generate_compile_method(@runner_path)
instance_eval <<~RUBY, __FILE__, __LINE__
def compile_source(source)
<<-RUNNER
#{IO.read(@runner_path)}
RUNNER
end
RUBY
end
end
@ -143,15 +149,6 @@ module ExecJS
end
protected
def generate_compile_method(path)
<<-RUBY
def compile_source(source)
<<-RUNNER
#{IO.read(path)}
RUNNER
end
RUBY
end
def json2_source
@json2_source ||= IO.read(ExecJS.root + "/support/json2.js")