mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -04:00
Use reference instead of primitive
This commit is contained in:
parent
670cf54957
commit
9489d6abfd
@ -143,10 +143,10 @@ class Library
|
||||
storage = Storage.new auto_close: false
|
||||
|
||||
examine_context : ExamineContext = {
|
||||
file_count: 0,
|
||||
file_counter: (YieldCounter.new 1000),
|
||||
cached_contents_signature: {} of String => String,
|
||||
deleted_title_ids: [] of String,
|
||||
deleted_entry_ids: [] of String
|
||||
deleted_title_ids: [] of String,
|
||||
deleted_entry_ids: [] of String,
|
||||
}
|
||||
|
||||
@title_ids.select! do |title_id|
|
||||
|
@ -115,7 +115,7 @@ class Title
|
||||
previous_entries_size = @entries.size
|
||||
@entries.select! do |entry|
|
||||
existence = File.exists? entry.zip_path
|
||||
yield_process_file context
|
||||
context["file_counter"].count_and_yield
|
||||
context["deleted_entry_ids"] << entry.id unless existence
|
||||
existence
|
||||
end
|
||||
|
@ -134,14 +134,21 @@ class TitleInfo
|
||||
end
|
||||
end
|
||||
|
||||
class YieldCounter
|
||||
setter threshold : Int32
|
||||
|
||||
def initialize(@threshold : Int32)
|
||||
@file_count = 0
|
||||
end
|
||||
|
||||
def count_and_yield
|
||||
@file_count += 1
|
||||
Fiber.yield if @file_count % @threshold == 0
|
||||
end
|
||||
end
|
||||
|
||||
alias ExamineContext = NamedTuple(
|
||||
file_count: Int32,
|
||||
file_counter: YieldCounter,
|
||||
cached_contents_signature: Hash(String, String),
|
||||
deleted_title_ids: Array(String),
|
||||
deleted_entry_ids: Array(String)
|
||||
)
|
||||
|
||||
def yield_process_file(context : ExamineContext)
|
||||
context["file_count"] += 1
|
||||
Fiber.yield if context["file_count"] % 1000 == 0
|
||||
end
|
||||
deleted_entry_ids: Array(String))
|
||||
|
Loading…
x
Reference in New Issue
Block a user