<commit_before>module SplitAccounts

  class OrderDetailListTransformer

    attr_reader :order_details

    def initialize(order_details = [])
      @order_details = order_details
    end

    def perform
      order_details.map do |order_detail|
        # We will need to refactor the general_reports_controller_spec in
        # order to remove the `try` methods below.
        if order_detail.account.try(:splits).try(:present?)
          SplitAccounts::OrderDetailSplitter.new(order_detail).build_split_order_details
        else
          order_detail
        end
      end.flatten
    end

  end

end
<commit_msg>[#120455] Improve performance of OrderDetail split transformer<commit_after>module SplitAccounts

  class OrderDetailListTransformer

    attr_reader :order_details

    def initialize(order_details = [])
      @order_details = order_details
    end

    def perform
      order_details.each_with_object([]) do |order_detail, results|
        # We will need to refactor the general_reports_controller_spec in
        # order to remove the `try` methods below.
        if order_detail.account.try(:splits).try(:present?)
          results.concat SplitAccounts::OrderDetailSplitter.new(order_detail).build_split_order_details
        else
          results << order_detail
        end
      end
    end

  end

end

{'fraction_non_alphanumeric': 0.06151537884471118, 'fraction_numerical': 0.00450112528132033, 'mean_word_length': 2.982089552238806, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2566500', 'n_tokens_mistral': 384, 'n_tokens_neox': 360, 'n_words': 91}