1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Freeze all the strings!

Reduces runtime allocation by freezing string literals by default.

We could also remove a ton of manual `.freeze` calls, however the ruby supported version is 2.2 and the magic comment only targets 2.3+.
This commit is contained in:
schneems 2018-09-17 11:41:14 -05:00
parent f7e1e58dcb
commit 88e51fb08e
29 changed files with 57 additions and 0 deletions

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'uri'
require 'socket'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'optparse'
require 'uri'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class IO
# We need to use this for a jruby work around on both 1.8 and 1.9.
# So this either creates the constant (on 1.8), or harmlessly

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'puma/runner'
require 'puma/util'
require 'puma/plugin'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Puma
# Rack::CommonLogger forwards every request to the given +app+, and
# logs a line in the

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'puma/rack/builder'
require 'puma/plugin'
require 'puma/const'

View file

@ -1,4 +1,6 @@
#encoding: utf-8
# frozen_string_literal: true
module Puma
class UnsupportedOption < RuntimeError
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'optparse'
require 'puma/state_file'
require 'puma/const'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'puma/launcher'
require 'puma/configuration'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Process
# This overrides the default version because it is broken if it

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Puma
module Delegation
def forward(what, who)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Puma
IS_JRUBY = defined?(JRUBY_VERSION)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Puma
# The methods that are available for use inside the config file.
# These same methods are used in Puma cli and the rack handler

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'puma/const'
require "puma/null_io"
require 'stringio'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'puma/detect'
if Puma.jruby?

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'java'
# Conservative native JRuby/Java implementation of IOBuffer

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'ffi'
module Puma

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'puma/events'
require 'puma/detect'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
begin
require 'io/wait'
rescue LoadError

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Puma
# Provides an IO-like object that always appears to contain no data.
# Used as the value for rack.input when the request has no body.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Puma
class UnknownPlugin < RuntimeError; end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'puma/util'
require 'puma/minissl'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'puma/server'
require 'puma/const'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'stringio'
require 'puma/thread_pool'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'puma/runner'
require 'puma/detect'
require 'puma/plugin'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'yaml'
module Puma

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Puma
class TCPLogger
def initialize(logger, app, quiet=false)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'thread'
module Puma

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
major, minor, patch = RUBY_VERSION.split('.').map { |v| v.to_i }
if major == 1 && minor == 9 && patch == 3 && RUBY_PATCHLEVEL < 125