From fa2448daa7d4d0fb50037f3b3cbbf754c81d5063 Mon Sep 17 00:00:00 2001 From: niku <10890+niku@users.noreply.github.com> Date: Sat, 17 Aug 2024 17:01:43 +0900 Subject: [PATCH] Remove unnecessary merges Merging the `kwargs` with the `@@default_kwargs` is needed only once before calling the `@block`. The method `sample` calls the method `call`, and the method `call` calls the method `generate`. Therefore, when merge processing is performed only at the `generate`, the merging processing will be executed only once by the `sample` and the `call`. --- lib/prop_check/generator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/prop_check/generator.rb b/lib/prop_check/generator.rb index 6933844..290cfae 100644 --- a/lib/prop_check/generator.rb +++ b/lib/prop_check/generator.rb @@ -55,7 +55,7 @@ def generate(**kwargs) # >> Generators.integer.call(size: 1000, rng: Random.new(42)) # => 126 def call(**kwargs) - generate(**@@default_kwargs.merge(kwargs)).root + generate(**kwargs).root end ## @@ -63,7 +63,7 @@ def call(**kwargs) # This is mostly useful for debugging if a generator behaves as you intend it to. def sample(num_of_samples = 10, **kwargs) num_of_samples.times.map do - call(**@@default_kwargs.merge(kwargs)) + call(**kwargs) end end