Skip to content

Commit

Permalink
Speed up nested #simple_fields_for usage by a considerable amount
Browse files Browse the repository at this point in the history
Exceptions are slow due to generating backtraces - and then when other
debugging gems (such as did_you mean, which are included with
Ruby and Rails these days) get involved it resulted in excessive Object
allocation.
  • Loading branch information
meanphil committed Feb 20, 2023
1 parent 0ef4a58 commit ff3903f
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions lib/simple_form/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -672,12 +672,7 @@ def mapping_override(klass)

def attempt_mapping(mapping, at)
return if SimpleForm.inputs_discovery == false && at == Object

begin
at.const_get(mapping)
rescue NameError => e
raise if e.message !~ /#{mapping}$/
end
return at.const_get(mapping) if at.const_defined?(mapping)
end

def attempt_mapping_with_custom_namespace(input_name)
Expand Down

0 comments on commit ff3903f

Please sign in to comment.