class Rage::Router::Constrainer

def __build_derive_constraints

This allows us to not allocate an object to hold constraint values if no constraints are defined.
If no constraining strategies are in use (no routes constrain on host, or version, or any custom strategies) then we don't need to derive constraints for each route match, so don't do anything special, and just return undefined
Optimization: build a fast function for deriving the constraints for all the strategies at once. We inline the definitions of the version constraint and the host constraint for performance.
def __build_derive_constraints
  return if @strategies_in_use.empty?
  lines = ["{"]
  @strategies_in_use.each do |key|
    strategy = @strategies[key]
    # Optimization: inline the derivation for the common built in constraints
    if !strategy.custom?
      if key == :host
        lines << "   host: env['HTTP_HOST'.freeze],"
      else
        raise ArgumentError, "unknown non-custom strategy for compiling constraint derivation function"
      end
    else
      lines << "  #{strategy.name}: @strategies[#{key}].derive_constraint(env),"
    end
  end
  lines << "}"
  instance_eval <<-RUBY
    def derive_constraints(env)
      #{lines.join("\n")}
    end
  RUBY
end