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:
parent
46da2d1e60
commit
cac943e891
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Generators
|
||||
class InstallGenerator < Rails::Generators::Base
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<%# frozen_string_literal: true %>
|
||||
<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
|
||||
<%%= f.error_notification %>
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
-# frozen_string_literal: true
|
||||
= simple_form_for(@<%= singular_table_name %>) do |f|
|
||||
= f.error_notification
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module ActionViewExtensions
|
||||
# This module creates SimpleForm wrappers around default form_for and fields_for.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Components
|
||||
module Errors
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Components
|
||||
# Needs to be enabled in order to do automatic lookups.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Components
|
||||
module HTML5
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Components
|
||||
module LabelInput
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Components
|
||||
module Labels
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Components
|
||||
# Needs to be enabled in order to do automatic lookups.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Components
|
||||
module MinMax
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Components
|
||||
# Needs to be enabled in order to do automatic lookups.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Components
|
||||
# Needs to be enabled in order to do automatic lookups.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Components
|
||||
# Needs to be enabled in order to do automatic lookups.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Components
|
||||
# Needs to be enabled in order to do automatic lookups.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
class ErrorNotification
|
||||
delegate :object, :object_name, :template, to: :@builder
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Helpers
|
||||
module Autofocus
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Helpers
|
||||
module Disabled
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Helpers
|
||||
module Readonly
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Helpers
|
||||
module Required
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Helpers
|
||||
module Validators
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
extend ActiveSupport::Autoload
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class BlockInput < Base
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class BooleanInput < Base
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class CollectionCheckBoxesInput < CollectionRadioButtonsInput
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class CollectionInput < Base
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class CollectionRadioButtonsInput < CollectionInput
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class CollectionSelectInput < CollectionInput
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class DateTimeInput < Base
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class FileInput < Base
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class GroupedCollectionSelectInput < CollectionInput
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class HiddenInput < Base
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class NumericInput < Base
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class PasswordInput < Base
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class PriorityInput < CollectionSelectInput
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class RangeInput < NumericInput
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class StringInput < Base
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Inputs
|
||||
class TextInput < Base
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'active_support/core_ext/class/attribute'
|
||||
|
||||
module SimpleForm
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'rails/railtie'
|
||||
|
||||
module SimpleForm
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Tags
|
||||
module CollectionExtensions
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
VERSION = "3.5.0".freeze
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Wrappers
|
||||
autoload :Builder, 'simple_form/wrappers/builder'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Wrappers
|
||||
# Provides the builder syntax for components. The builder provides
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Wrappers
|
||||
class Leaf
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Wrappers
|
||||
# A wrapper is an object that holds several components and render them.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SimpleForm
|
||||
module Wrappers
|
||||
# `Single` is an optimization for a wrapper that has only one component.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class BuilderTest < ActionView::TestCase
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class FormHelperTest < ActionView::TestCase
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for f.error and f.full_error
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for f.hint
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
# Tests for f.input_field
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class WrapperTest < ActionView::TestCase
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class SimpleFormGeneratorTest < Rails::Generators::TestCase
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class DisabledTest < ActionView::TestCase
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class DiscoveryTest < ActionView::TestCase
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class ReadonlyTest < ActionView::TestCase
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class RequiredTest < ActionView::TestCase
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class SimpleFormTest < ActiveSupport::TestCase
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class StringInput < SimpleForm::Inputs::StringInput
|
||||
def input(wrapper_options = nil)
|
||||
"<section>#{super}</section>".html_safe
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module MiscHelpers
|
||||
def store_translations(locale, translations, &block)
|
||||
I18n.backend.store_translations locale, translations
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class MockController
|
||||
attr_writer :action_name
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
Association = Struct.new(:klass, :name, :macro, :scope, :options)
|
||||
|
||||
Column = Struct.new(:name, :type, :limit) do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'bundler/setup'
|
||||
|
||||
require 'minitest/autorun'
|
||||
|
|
Loading…
Reference in New Issue