From 9769e760a0ad0ce9035ad350185497942b280795 Mon Sep 17 00:00:00 2001 From: Leeingnyo Date: Thu, 16 Sep 2021 07:49:12 +0900 Subject: [PATCH] Pass a counter to recursive calls, Ignore negative threshold --- src/library/types.cr | 4 ++-- src/util/signature.cr | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/library/types.cr b/src/library/types.cr index 7856660..a0e0428 100644 --- a/src/library/types.cr +++ b/src/library/types.cr @@ -135,7 +135,7 @@ class TitleInfo end class YieldCounter - setter threshold : Int32 + @file_count : UInt32 def initialize(@threshold : Int32) @file_count = 0 @@ -143,7 +143,7 @@ class YieldCounter def count_and_yield @file_count += 1 - Fiber.yield if @file_count % @threshold == 0 + Fiber.yield if @threshold > 0 && @file_count % @threshold == 0 end end diff --git a/src/util/signature.cr b/src/util/signature.cr index 59a8311..76e2628 100644 --- a/src/util/signature.cr +++ b/src/util/signature.cr @@ -65,7 +65,7 @@ class Dir next if fn.starts_with? "." path = File.join dirname, fn if File.directory? path - signatures << Dir.contents_signature path, cache + signatures << Dir.contents_signature path, cache, counter else # Only add its signature value to `signatures` when it is a # supported file