Use a find instead of an each loop

This commit is contained in:
ChunkyProgrammer 2024-07-10 09:26:31 -04:00
parent 6b0e4e6817
commit bba1769f4b

View File

@ -291,10 +291,9 @@ struct Invidious::User
def from_newpipe(user : User, body : String) : Bool
Compress::Zip::File.open(IO::Memory.new(body), true) do |file|
file.entries.each do |entry|
entry = file.entries.find { |file_entry| file_entry.filename == "newpipe.db" }
return false if entry.nil?
entry.open do |file_io|
next if entry.filename != "newpipe.db"
# Ensure max size of 4MB
io_sized = IO::Sized.new(file_io, 0x400000)
@ -327,7 +326,6 @@ struct Invidious::User
end
end
end
end
# Success!
return true