From 5308efaef1401632ed7257a4991e2797bba36290 Mon Sep 17 00:00:00 2001 From: schneems Date: Mon, 20 May 2019 14:02:48 -0500 Subject: [PATCH] [close #383] Remove duplicate check All assets will be digested which forces the use of only specified classes. This check is a duplicate and isn't terribly informative. Removing it gives us significant speed improvements. --- lib/sprockets/processor_utils.rb | 20 -------------------- test/test_processor_utils.rb | 5 +---- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/lib/sprockets/processor_utils.rb b/lib/sprockets/processor_utils.rb index 86ab7d433..9d2943c38 100644 --- a/lib/sprockets/processor_utils.rb +++ b/lib/sprockets/processor_utils.rb @@ -161,29 +161,9 @@ def validate_processor_result!(result) if !key.instance_of?(Symbol) raise TypeError, "processor metadata[#{key.inspect}] expected to be a Symbol" end - - if !valid_processor_metadata_value?(value) - raise TypeError, "processor metadata[:#{key}] returned a complex type: #{value.inspect}\n" + - "Only #{VALID_METADATA_TYPES.to_a.join(", ")} maybe used." - end end result end - - # Internal: Validate object is in validate metadata whitelist. - # - # value - Any Object - # - # Returns true if class is in whitelist otherwise false. - def valid_processor_metadata_value?(value) - if VALID_METADATA_VALUE_TYPES_HASH[value.class] - true - elsif VALID_METADATA_COMPOUND_TYPES_HASH[value.class] - value.all? { |v| valid_processor_metadata_value?(v) } - else - false - end - end end end diff --git a/test/test_processor_utils.rb b/test/test_processor_utils.rb index ee07717d0..01f92ae21 100644 --- a/test/test_processor_utils.rb +++ b/test/test_processor_utils.rb @@ -348,9 +348,6 @@ def test_validate_processor_result assert_raises(TypeError) { validate_processor_result!({data: 123}) } assert_raises(TypeError) { validate_processor_result!({data: "hello", "foo" => 1}) } assert_raises(TypeError) { validate_processor_result!({data: my_string.new("hello")}) } - assert_raises(TypeError) { validate_processor_result!({data: "hello", foo: Object.new}) } - assert_raises(TypeError) { validate_processor_result!({data: "hello", foo: [Object.new]}) } - assert_raises(TypeError) { validate_processor_result!({data: "hello", foo: Set.new([Object.new])}) } - assert_raises(TypeError) { validate_processor_result!({data: "hello", foo: {bar: Object.new}}) } end end +