Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #586 from technicalpickles/frozen-string-literals
Browse files Browse the repository at this point in the history
Reduce memory usage by using frozen string literals
  • Loading branch information
JonRowe committed Feb 4, 2024
1 parent 68b8508 commit 7be928d
Show file tree
Hide file tree
Showing 35 changed files with 72 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ Lint/AssignmentInCondition:
Exclude:
# The pattern makes sense here
- 'lib/rspec/support/mutex.rb'

Style/FrozenStringLiteralComment:
Include:
- lib/**/*.rb
Layout/EmptyLineAfterMagicComment:
Enabled: true
7 changes: 0 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,6 @@ Style/FormatString:
Exclude:
- 'spec/rspec/support/encoded_string_spec.rb'

# Offense count: 68
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/GlobalStdStream:
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpec
module Support
# @api private
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/caller_filter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec::Support.require_rspec_support "ruby_features"

module RSpec
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/comparable_version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpec
module Support
# @private
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/differ.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec::Support.require_rspec_support 'encoded_string'
RSpec::Support.require_rspec_support 'hunk_generator'
RSpec::Support.require_rspec_support "object_formatter"
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/directory_maker.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec::Support.require_rspec_support 'ruby_features'

module RSpec
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/encoded_string.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpec
module Support
# @private
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/fuzzy_matcher.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpec
module Support
# Provides a means to fuzzy-match between two arbitrary objects.
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/hunk_generator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'diff/lcs'
require 'diff/lcs/hunk'

Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/matcher_definition.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpec
module Support
# @private
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/method_signature_verifier.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rspec/support'
RSpec::Support.require_rspec_support "ruby_features"
RSpec::Support.require_rspec_support "matcher_definition"
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/mutex.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpec
module Support
# On 1.8.7, it's in the stdlib.
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/object_formatter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec::Support.require_rspec_support 'matcher_definition'

module RSpec
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/recursive_const_methods.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpec
module Support
# Provides recursive constant lookup methods useful for
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/reentrant_mutex.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpec
module Support
# Allows a thread to lock out other threads from a critical section of code,
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/ruby_features.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rbconfig'
RSpec::Support.require_rspec_support "comparable_version"

Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/source.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec::Support.require_rspec_support 'encoded_string'
RSpec::Support.require_rspec_support 'ruby_features'

Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/source/location.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpec
module Support
class Source
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/source/node.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec::Support.require_rspec_support 'source/location'

module RSpec
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/source/token.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec::Support.require_rspec_support 'source/location'

module RSpec
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rspec/support'
require 'rspec/support/spec/in_sub_process'

Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/spec/deprecation_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpecHelpers
def expect_deprecation_with_call_site(file, line, snippet=//)
expect(RSpec.configuration.reporter).to receive(:deprecation).
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/spec/diff_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'diff/lcs'

module RSpec
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/spec/formatting_support.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpec
module Support
module FormattingSupport
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/spec/in_sub_process.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpec
module Support
module InSubProcess
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/spec/library_wide_checks.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rspec/support/spec/shell_out'

module RSpec
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/spec/shell_out.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'open3'
require 'rake/file_utils'
require 'shellwords'
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/spec/stderr_splitter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'stringio'

module RSpec
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/spec/string_matcher.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rspec/matchers'
# Special matcher for comparing encoded strings so that
# we don't run any expectation failures through the Differ,
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/spec/with_isolated_directory.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'tmpdir'

RSpec.shared_context "isolated directory" do
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/spec/with_isolated_stderr.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpec
module Support
module WithIsolatedStdErr
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RSpec
module Support
module Version
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/warnings.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rspec/support'
RSpec::Support.require_rspec_support "caller_filter"

Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/support/with_keywords_when_needed.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec::Support.require_rspec_support("method_signature_verifier")

module RSpec
Expand Down

0 comments on commit 7be928d

Please sign in to comment.