From cac0f9bedc120aebb353b431b3393168e4a06976 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 14 Aug 2015 09:40:31 +0000 Subject: [PATCH] win32/registry.rb: make @@type2name an array * ext/win32/lib/win32/registry.rb (@@type2name): make an array instead of a hash, keys are sequential numbers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/win32/lib/win32/registry.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ext/win32/lib/win32/registry.rb b/ext/win32/lib/win32/registry.rb index f0166d69b9..1e12f4bafc 100644 --- a/ext/win32/lib/win32/registry.rb +++ b/ext/win32/lib/win32/registry.rb @@ -377,15 +377,16 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr } end - @@type2name = { } - %w[ + @@type2name = %w[ REG_NONE REG_SZ REG_EXPAND_SZ REG_BINARY REG_DWORD REG_DWORD_BIG_ENDIAN REG_LINK REG_MULTI_SZ REG_RESOURCE_LIST REG_FULL_RESOURCE_DESCRIPTOR REG_RESOURCE_REQUIREMENTS_LIST REG_QWORD - ].each do |type| - @@type2name[Constants.const_get(type)] = type - end + ].inject([]) do |ary, type| + type.freeze + ary[Constants.const_get(type)] = type + ary + end.freeze # # Convert registry type value to readable string.