Skip to content

Commit d7e98cd

Browse files
authored
Merge pull request #620 from tenderlove/freeze
Freeze strings and constants in pragmas
2 parents 2724f7b + e734b9f commit d7e98cd

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/sqlite3/pragmas.rb

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "sqlite3/errors"
24

35
module SQLite3
@@ -77,26 +79,26 @@ def set_int_pragma(name, value)
7779
end
7880

7981
# The enumeration of valid synchronous modes.
80-
SYNCHRONOUS_MODES = [["full", 2], ["normal", 1], ["off", 0]]
82+
SYNCHRONOUS_MODES = [["full", 2], ["normal", 1], ["off", 0]].map(&:freeze).freeze
8183

8284
# The enumeration of valid temp store modes.
83-
TEMP_STORE_MODES = [["default", 0], ["file", 1], ["memory", 2]]
85+
TEMP_STORE_MODES = [["default", 0], ["file", 1], ["memory", 2]].map(&:freeze).freeze
8486

8587
# The enumeration of valid auto vacuum modes.
86-
AUTO_VACUUM_MODES = [["none", 0], ["full", 1], ["incremental", 2]]
88+
AUTO_VACUUM_MODES = [["none", 0], ["full", 1], ["incremental", 2]].map(&:freeze).freeze
8789

8890
# The list of valid journaling modes.
8991
JOURNAL_MODES = [["delete"], ["truncate"], ["persist"], ["memory"],
90-
["wal"], ["off"]]
92+
["wal"], ["off"]].map(&:freeze).freeze
9193

9294
# The list of valid locking modes.
93-
LOCKING_MODES = [["normal"], ["exclusive"]]
95+
LOCKING_MODES = [["normal"], ["exclusive"]].map(&:freeze).freeze
9496

9597
# The list of valid encodings.
96-
ENCODINGS = [["utf-8"], ["utf-16"], ["utf-16le"], ["utf-16be"]]
98+
ENCODINGS = [["utf-8"], ["utf-16"], ["utf-16le"], ["utf-16be"]].map(&:freeze).freeze
9799

98100
# The list of valid WAL checkpoints.
99-
WAL_CHECKPOINTS = [["passive"], ["full"], ["restart"], ["truncate"]]
101+
WAL_CHECKPOINTS = [["passive"], ["full"], ["restart"], ["truncate"]].map(&:freeze).freeze
100102

101103
def application_id
102104
get_int_pragma "application_id"

0 commit comments

Comments
 (0)