Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-3112

Freeze string literals for Ruby

    XMLWordPrintableJSON

Details

    • Task
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.10.2
    • 1.11.0
    • ruby
    • None

    Description

      Since Ruby 2.3 there has been an option to freeze all string literals. This improves both performance by eliminating unnecessary allocations for duplicate strings and reliability by preventing mutation of values.

      A comment can be added to the top of each Ruby file to freeze all string literals:

      # frozen_string_literal: true

      The RuboCop linting tool can be used to used to ensure that this is present for all files. Additional checks can be used to identity and remove existing calls to `.freeze` that are redundant once this comment is added.

      Attachments

        Issue Links

          Activity

            People

              tjwp Tim Perkins
              tjwp Tim Perkins
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: