<commit_before>module Jei
  module Nodes
    # @see http://jsonapi.org/format/#document-top-level
    class CollectionDataNode < DataNode
      # @param [Hash<Symbol, Object>] context
      def visit(context)
        context[:data] = children.map do |child|
          data = {}
          child.visit(data)
          data
        end
      end
    end
  end
end<commit_msg>Quick return an empty list if a collection is empty<commit_after>module Jei
  module Nodes
    # @see http://jsonapi.org/format/#document-top-level
    class CollectionDataNode < DataNode
      EMPTY_LIST = [].freeze

      # @param [Hash<Symbol, Object>] context
      def visit(context)
        context[:data] =
          if children.empty?
            EMPTY_LIST
          else
            children.map do |child|
              data = {}
              child.visit(data)
              data
            end
          end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08686210640608034, 'fraction_numerical': 0.0, 'mean_word_length': 1.71976401179941, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '958879', 'n_tokens_mistral': 263, 'n_tokens_neox': 257, 'n_words': 69}