Skip to content

Commit

Permalink
Freeze encoding maps
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianna-chang-shopify committed Apr 5, 2023
1 parent 960aa62 commit c98af25
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions contrib/ruby/lib/trilogy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "trilogy/version"

class Trilogy
Expand Down Expand Up @@ -149,7 +151,7 @@ class ConnectionClosed < IOError
"eucjpms" => "eucJP-ms",
"utf16le" => "UTF-16LE",
"gb18030" => "GB18030",
}
}.freeze

def initialize(options = {})
mysql_encoding = options[:encoding] || "utf8mb4"
Expand Down Expand Up @@ -228,7 +230,7 @@ def each(&bk)

def charset_for_mysql_encoding(mysql_encoding)
@mysql_encodings_map ||= {
"big5" => CHARSET_BIG5_CHINESE_CI,
"big5" => CHARSET_BIG5_CHINESE_CI,
"cp850" => CHARSET_CP850_GENERAL_CI,
"koi8r" => CHARSET_KOI8R_GENERAL_CI,
"latin1" => CHARSET_LATIN1_GENERAL_CI,
Expand Down Expand Up @@ -263,7 +265,7 @@ def charset_for_mysql_encoding(mysql_encoding)
"cp1257" => CHARSET_CP1257_GENERAL_CI,
"utf32" => CHARSET_UTF32_GENERAL_CI,
"binary" => CHARSET_BINARY,
}
}.freeze
@mysql_encodings_map[mysql_encoding]
end
end
Expand Down

0 comments on commit c98af25

Please sign in to comment.