mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Avoid anonymous eval
This makes it hard to track down the source of allocations and such when profiling.
This commit is contained in:
parent
e553b3f8a3
commit
1c1770d8b0
1 changed files with 7 additions and 10 deletions
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue