Skip to content

Commit ff3903f

Browse files
committed
Speed up nested #simple_fields_for usage by a considerable amount
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.
1 parent 0ef4a58 commit ff3903f

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

lib/simple_form/form_builder.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -672,12 +672,7 @@ def mapping_override(klass)
672672

673673
def attempt_mapping(mapping, at)
674674
return if SimpleForm.inputs_discovery == false && at == Object
675-
676-
begin
677-
at.const_get(mapping)
678-
rescue NameError => e
679-
raise if e.message !~ /#{mapping}$/
680-
end
675+
return at.const_get(mapping) if at.const_defined?(mapping)
681676
end
682677

683678
def attempt_mapping_with_custom_namespace(input_name)

0 commit comments

Comments
 (0)