Skip to content

Commit

Permalink
Added disable_visit_errors option to Parser
Browse files Browse the repository at this point in the history
This adds a way to disable all errors during the .visit(object) stage. Parse errors will still be raised, but runtime exceptions such as values being of the wrong type for a function will be ignored. Benchmarks show a 40% speedup in MRI and 500% in JRuby.
  • Loading branch information
David Dahl committed Sep 17, 2015
1 parent 92cc0ab commit 5703438
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 62 deletions.
4 changes: 2 additions & 2 deletions lib/jmespath.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class << self
# @param [Hash] data
# @return [Mixed,nil] Returns the matched values. Returns `nil` if the
# expression does not resolve inside `data`.
def search(expression, data)
def search(expression, data, runtime_options = {})
data = case data
when Hash, Struct then data # check for most common case first
when Pathname then load_json(data)
when IO, StringIO then JSON.load(data.read)
else data
end
Runtime.new.search(expression, data)
Runtime.new(runtime_options).search(expression, data)
end

# @api private
Expand Down
Loading

0 comments on commit 5703438

Please sign in to comment.