Skip to content

Commit

Permalink
Use Set instead of Array for warn & debug messages
Browse files Browse the repository at this point in the history
Prior to this commit, Facter's logger used Arrays to store warn and
debug messages. When using the warnonce and debugonce options, Facter
would call #include? on the warn and debug arrays.

This commit updates Facter to use Sets instead of Arrays to store warn
and debug messages, making it more performant to search through the
messages (i.e. call #include?).
  • Loading branch information
mhashizume committed May 3, 2024
1 parent d04a42d commit 436be42
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/facter/framework/logging/logger.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'logger'
require 'set'

module Facter
RED = "\e[31m"
Expand All @@ -15,8 +16,8 @@ class Log
@@logger = nil
@@message_callback = nil
@@has_errors = false
@@debug_messages = []
@@warn_messages = []
@@debug_messages = Set.new
@@warn_messages = Set.new
@@timing = false

class << self
Expand Down

0 comments on commit 436be42

Please sign in to comment.