<commit_before># encoding: utf-8

module IceNine

  # Protect against infinite recursion
  class RecursionGuard

    # Initialize a recursion guard
    #
    # @return [undefined]
    #
    # @api public
    def initialize
      @object_ids = Set.new
    end

    # Guard against recursively calling a block with the same object
    #
    # @example
    #  recursion_guard = IceNine::RecursionGuard.new
    #  recursion_guard.guard(object_id) do
    #    logic_which_may_be_recursively_called_with_object_id(recursion_guard)
    #  end
    #
    # @param [Integer] caller_object_id
    #
    # @return [Object]
    #
    # @api public
    def guard(caller_object_id)
      return if @object_ids.include?(caller_object_id)
      begin
        @object_ids << caller_object_id
        yield
      ensure
        @object_ids.delete(caller_object_id)
      end
    end

  end # RecursionGuard
end # module IceNine
<commit_msg>Don't delete object IDs from recursion guard<commit_after># encoding: utf-8

module IceNine

  # Protect against infinite recursion
  class RecursionGuard

    # Initialize a recursion guard
    #
    # @return [undefined]
    #
    # @api public
    def initialize
      @object_ids = Set.new
    end

    # Guard against recursively calling a block with the same object
    #
    # @example
    #  recursion_guard = IceNine::RecursionGuard.new
    #  recursion_guard.guard(object_id) do
    #    logic_which_may_be_recursively_called_with_object_id(recursion_guard)
    #  end
    #
    # @param [Integer] caller_object_id
    #
    # @return [Object]
    #
    # @api public
    def guard(caller_object_id)
      return if @object_ids.include?(caller_object_id)
      begin
        @object_ids << caller_object_id
        yield
      end
    end

  end # RecursionGuard
end # module IceNine

{'fraction_non_alphanumeric': 0.0699724517906336, 'fraction_numerical': 0.0011019283746556473, 'mean_word_length': 2.632, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '117129', 'n_tokens_mistral': 596, 'n_tokens_neox': 576, 'n_words': 136}