Add frozen_string_literal in all .rb files

I noticed these files all had strings such as "", "  ", "_" that were
allocated each time some common methods were called, over 1000x on a
page in my app. This comment freezes all of these strings such that
they're only allocated once, saving many KB of memory allocation.
This commit is contained in:
Dillon Welch 2017-10-23 18:01:08 -07:00
parent 46da2d1e60
commit cac943e891
94 changed files with 94 additions and 0 deletions

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Generators
class InstallGenerator < Rails::Generators::Base

View File

@ -1,3 +1,4 @@
<%# frozen_string_literal: true %>
<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
<%%= f.error_notification %>

View File

@ -1,3 +1,4 @@
-# frozen_string_literal: true
= simple_form_for(@<%= singular_table_name %>) do |f|
= f.error_notification

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.error_notification_class = 'alert alert-danger'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Don't forget to edit this file to adapt it to your needs (specially

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'action_view'
require 'simple_form/action_view_extensions/form_helper'
require 'simple_form/action_view_extensions/builder'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module ActionViewExtensions
# A collection of methods required by simple_form but added to rails default form.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module ActionViewExtensions
# This module creates SimpleForm wrappers around default form_for and fields_for.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
# Components are a special type of helpers that can work on their own.
# For example, by using a component, it will automatically change the

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Components
module Errors

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Components
module HTML5

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Components
module LabelInput

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Components
module Labels

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Components
module MinMax

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Components
# Needs to be enabled in order to do automatic lookups.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
class ErrorNotification
delegate :object, :object_name, :template, to: :@builder

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'active_support/core_ext/object/deep_dup'
require 'simple_form/map_type'
require 'simple_form/tags'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
# Helpers are made of several helpers that cannot be turned on automatically.
# For instance, disabled cannot be turned on automatically, it requires the

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Helpers
module Autofocus

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Helpers
module Disabled

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Helpers
module Readonly

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Helpers
module Required

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Helpers
module Validators

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
# A lot of configuration values are retrived from I18n,
# like boolean collection, required string. This module provides

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
extend ActiveSupport::Autoload

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'simple_form/i18n_cache'
require 'active_support/core_ext/string/output_safety'
require 'action_view/helpers'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class BlockInput < Base

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class BooleanInput < Base

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class CollectionCheckBoxesInput < CollectionRadioButtonsInput

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class CollectionInput < Base

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class CollectionRadioButtonsInput < CollectionInput

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class CollectionSelectInput < CollectionInput

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class DateTimeInput < Base

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class FileInput < Base

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class GroupedCollectionSelectInput < CollectionInput

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class HiddenInput < Base

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class NumericInput < Base

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class PasswordInput < Base

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class PriorityInput < CollectionSelectInput

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class RangeInput < NumericInput

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class StringInput < Base

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class TextInput < Base

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'active_support/core_ext/class/attribute'
module SimpleForm

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rails/railtie'
module SimpleForm

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Tags
module CollectionExtensions

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
VERSION = "3.5.0".freeze
end

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Wrappers
autoload :Builder, 'simple_form/wrappers/builder'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Wrappers
# Provides the builder syntax for components. The builder provides

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Wrappers
class Leaf

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Wrappers
# A wrapper is an object that holds several components and render them.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Wrappers
# `Root` is the root wrapper for all components. It is special cased to

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SimpleForm
module Wrappers
# `Single` is an optimization for a wrapper that has only one component.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'
class BuilderTest < ActionView::TestCase

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'
class FormHelperTest < ActionView::TestCase

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'
# Tests for f.error and f.full_error

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'
# Tests for f.hint

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'
# Tests for f.input_field

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'
class WrapperTest < ActionView::TestCase

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'
class SimpleFormGeneratorTest < Rails::Generators::TestCase

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'
class DisabledTest < ActionView::TestCase

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'
class DiscoveryTest < ActionView::TestCase

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'
class ReadonlyTest < ActionView::TestCase

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'
class RequiredTest < ActionView::TestCase

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# encoding: UTF-8
require 'test_helper'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper'
class SimpleFormTest < ActiveSupport::TestCase

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
class StringInput < SimpleForm::Inputs::StringInput
def input(wrapper_options = nil)
"<section>#{super}</section>".html_safe

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module MiscHelpers
def store_translations(locale, translations, &block)
I18n.backend.store_translations locale, translations

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MockController
attr_writer :action_name

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Association = Struct.new(:klass, :name, :macro, :scope, :options)
Column = Struct.new(:name, :type, :limit) do

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'bundler/setup'
require 'minitest/autorun'