<commit_before>class UserAgent
  module Browsers
    class InternetExplorer < Base
      def self.extend?(agent)
        agent.application &&
        agent.application.comment &&
        (agent.application.comment[1] =~ /MSIE/ ||
         agent.application.comment.join('; ') =~ /Trident.+rv:/)
      end

      def browser
        "Internet Explorer"
      end

      def version
        str = application.comment.join('; ')[/(MSIE\s|rv:)([\d\.]+)/, 2]
        Version.new(str)
      end

      def trident_version
        if trident = application.comment.detect { |c| c['Trident/'] }
          trident_engines = Hash.new(trident).merge({
            "Trident/7.0" => "11.0",
            "Trident/6.0" => "10.0",
            "Trident/5.0" => "9.0",
            "Trident/4.0" => "8.0"
          })
          trident_engines[trident] && Version.new(trident_engines[trident])
        end
      end
<commit_msg>Trident engines lookup to avoid Hash allocation<commit_after>class UserAgent
  module Browsers
    class InternetExplorer < Base
      TRIDENT_ENGINES = {
        "Trident/7.0" => "11.0",
        "Trident/6.0" => "10.0",
        "Trident/5.0" => "9.0",
        "Trident/4.0" => "8.0",
      }.freeze

      def self.extend?(agent)
        agent.application &&
        agent.application.comment &&
        (agent.application.comment[1] =~ /MSIE/ ||
         agent.application.comment.join('; ') =~ /Trident.+rv:/)
      end

      def browser
        "Internet Explorer"
      end

      def version
        str = application.comment.join('; ')[/(MSIE\s|rv:)([\d\.]+)/, 2]
        Version.new(str)
      end

      def trident_version
        if trident = application.comment.detect { |c| c['Trident/'] }
          trident_version = TRIDENT_ENGINES.fetch(trident, trident)
          Version.new(trident_version)
        end
      end

{'fraction_non_alphanumeric': 0.15154807170016296, 'fraction_numerical': 0.021727322107550243, 'mean_word_length': 1.9238095238095239, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '4813848', 'n_tokens_mistral': 625, 'n_tokens_neox': 600, 'n_words': 108}