From 400954ebb510e73cc10cc169f8e0b038126f8150 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Sat, 29 Oct 2022 21:44:06 +0200 Subject: [PATCH] Use `String#hash` instead of `Digest::SHA1.hexdigest` --- src/ameba/runner.cr | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ameba/runner.cr b/src/ameba/runner.cr index 877d7b8f..ffe56d48 100644 --- a/src/ameba/runner.cr +++ b/src/ameba/runner.cr @@ -1,5 +1,3 @@ -require "digest" - module Ameba # Represents a runner for inspecting sources files. # Holds a list of rules to do inspection based on, @@ -186,7 +184,7 @@ module Ameba # Keep track of the state of the source. If a rule modifies the source # and another rule undoes it producing identical source we have an # infinite loop. - processed_sources = [] of String + processed_sources = [] of UInt64 # It is possible for a rule to keep adding indefinitely to a file, # making it bigger and bigger. If the inspection loop runs for an @@ -207,7 +205,7 @@ module Ameba # Check whether a run created source identical to a previous run, which # means that we definitely have an infinite loop. private def check_for_infinite_loop(source, corrected_issues, processed_sources) - checksum = Digest::SHA1.hexdigest(source.code) + checksum = source.code.hash if loop_start = processed_sources.index(checksum) raise InfiniteCorrectionLoopError.new(