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
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

This comment has been minimized.

Copy link
@BeatyThomas

BeatyThomas Oct 31, 2023

Just upgraded from 5.1.0 to 5.3.0 on Rails 5.2 (I know, it is a work in progress.)

Removing this prevents loading of custom inputs in app/inputs

This comment has been minimized.

Copy link
@terryyin

terryyin Nov 8, 2023

Yes. Trying a workaround for now. Would like to get updated when this get resolved (this change prevent loading custom inputs).

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.