<commit_before>require "rack/pipe/version"

module Rack
  class Pipe
    def initialize(*pipe_wares)
      @pipe_wares = pipe_wares
    end

    def new(app)
      @app = app
      self
    end

    def call(env)
      @pipe_wares.each do |ware|
        if ware.respond_to?(:before)
          status, headers, body = ware.before(env)
          return status, headers, body if status
        end
      end

      status, headers, body = @app.call(env)

      @pipe_wares.each do |ware|
        if ware.respond_to?(:after)
          status, headers, body = ware.after(env, status, headers, body)
        end
      end<commit_msg>performance<commit_after>require "rack/pipe/version"

module Rack
  class Pipe
    def initialize(*pipe_wares)
      @before = pipe_wares.select { |p| p.respond_to?(:before) }
      @after = pipe_wares.select { |p| p.respond_to?(:after) }
    end

    def new(app)
      @app = app
      self
    end

    def call(env)
      @before.each do |ware|
        status, headers, body = ware.before(env)
        return status, headers, body if status
      end

      status, headers, body = @app.call(env)

      @after.each do |ware|
        status, headers, body = ware.after(env, status, headers, body)
      end
{'fraction_non_alphanumeric': 0.10670978172999192, 'fraction_numerical': 0.0, 'mean_word_length': 2.2239583333333335, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1727048', 'n_tokens_mistral': 410, 'n_tokens_neox': 398, 'n_words': 107}