<commit_before>module SecureHeaders
  module DynamicConfig
    def self.included(base)
      base.send(:attr_writer, :modified)
      base.send(:attr_reader, *base.attrs)
      base.attrs.each do |attr|
        base.send(:define_method, "#{attr}=") do |value|
          if self.class.attrs.include?(attr)
            value = value.dup if PolicyManagement::DIRECTIVE_VALUE_TYPES[attr] == :source_list
            prev_value = self.instance_variable_get("@#{attr}")
            self.instance_variable_set("@#{attr}", value)
            if prev_value != self.instance_variable_get("@#{attr}")
              @modified = true
            end
          else
            raise ContentSecurityPolicyConfigError, "Unknown config directive: #{attr}=#{value}"
          end
        end
      end
    end

    def initialize(hash)
      from_hash(hash)
      @modified = false
    end
<commit_msg>Cache instance variable name to prevent creating the same string 3 times<commit_after>module SecureHeaders
  module DynamicConfig
    def self.included(base)
      base.send(:attr_writer, :modified)
      base.send(:attr_reader, *base.attrs)
      base.attrs.each do |attr|
        base.send(:define_method, "#{attr}=") do |value|
          if self.class.attrs.include?(attr)
            value = value.dup if PolicyManagement::DIRECTIVE_VALUE_TYPES[attr] == :source_list
            attr_variable = "@#{attr}"
            prev_value = self.instance_variable_get(attr_variable)
            self.instance_variable_set(attr_variable, value)
            if prev_value != self.instance_variable_get(attr_variable)
              @modified = true
            end
          else
            raise ContentSecurityPolicyConfigError, "Unknown config directive: #{attr}=#{value}"
          end
        end
      end
    end

    def initialize(hash)
      from_hash(hash)
      @modified = false
    end

{'fraction_non_alphanumeric': 0.10175812466702185, 'fraction_numerical': 0.0005327650506126798, 'mean_word_length': 2.458563535911602, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4228370', 'n_tokens_mistral': 523, 'n_tokens_neox': 523, 'n_words': 115}