From 262c52d1e57344d7c732cdc8150edcd152d11fcb Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Sat, 12 Oct 2013 19:58:38 +0900 Subject: [PATCH] Remove memoization Because it may return a wrong value when memoization hash collision is occurred. If performance problem is occurred, we should write benchmark program and them improve performance. --- lib/gettext/class_info.rb | 6 ------ lib/gettext/locale_path.rb | 7 ------- test/test_locale_path.rb | 4 ---- 3 files changed, 17 deletions(-) diff --git a/lib/gettext/class_info.rb b/lib/gettext/class_info.rb index 46f0665..9f99cc6 100644 --- a/lib/gettext/class_info.rb +++ b/lib/gettext/class_info.rb @@ -1,15 +1,11 @@ # -*- coding: utf-8 -*- -require 'locale/util/memoizable' - module GetText # For normalize/finding the related classes/modules. # This is used for realizing the scope of TextDomain. # (see: http://www.yotabanana.com/hiki/ruby-gettext-scope.html) module ClassInfo extend self - include Locale::Util::Memoizable - # normalize the class name # klass should kind of the class, not object. def normalize_class(klass) @@ -23,7 +19,6 @@ def normalize_class(klass) def root_ancestors # :nodoc: Object.ancestors end - memoize :root_ancestors # Internal method for related_classes. def related_classes_internal(klass, all_classes = [], analyzed_classes = [] ) @@ -64,6 +59,5 @@ def related_classes(klass, all_classes = []) end ret end - memoize :related_classes end end diff --git a/lib/gettext/locale_path.rb b/lib/gettext/locale_path.rb index a0445c3..a6c1706 100644 --- a/lib/gettext/locale_path.rb +++ b/lib/gettext/locale_path.rb @@ -15,8 +15,6 @@ module GetText # Treats locale-path for mo-files. class LocalePath - include Locale::Util::Memoizable - # The default locale paths. CONFIG_PREFIX = RbConfig::CONFIG['prefix'].gsub(/\/local/, "") DEFAULT_RULES = [ @@ -29,8 +27,6 @@ class LocalePath ].uniq class << self - include Locale::Util::Memoizable - # Add default locale path. Usually you should use GetText.add_default_locale_path instead. # * path: a new locale path. (e.g.) "/usr/share/locale/%{lang}/LC_MESSAGES/%{name}.mo" # ('locale' => "ja_JP", 'name' => "textdomain") @@ -66,7 +62,6 @@ def default_path_rules Dir.glob(path % {:lang => "*", :name => "*"}).size > 0}.uniq default_path_rules end - memoize_dup :default_path_rules end attr_reader :locale_paths, :supported_locales @@ -114,7 +109,5 @@ def current_path(lang) end nil end - memoize :current_path - end end diff --git a/test/test_locale_path.rb b/test/test_locale_path.rb index 084ffbf..d0556d4 100644 --- a/test/test_locale_path.rb +++ b/test/test_locale_path.rb @@ -25,7 +25,6 @@ class TestLocalePath < Test::Unit::TestCase def setup GetText.locale = "ja_JP.eucJP" - GetText::LocalePath.clear end def teardown @@ -78,12 +77,10 @@ def test_env_GETTEXT_PATH path1 = File.join(topdir, "locale") path2 = File.join(topdir, "cgi", "locale") - GetText::LocalePath.memoize_clear ENV["GETTEXT_PATH"] = path1 default_path_rules = GetText::LocalePath.default_path_rules assert_match(Regexp.compile(path1), default_path_rules[0]) - GetText::LocalePath.memoize_clear ENV["GETTEXT_PATH"] = "#{path1},#{path2}" default_path_rules = GetText::LocalePath.default_path_rules assert_match(Regexp.compile(path1), default_path_rules[0]) @@ -92,7 +89,6 @@ def test_env_GETTEXT_PATH class TestDefaultPathRules < self def test_load_path_untached - GetText::LocalePath.memoize_clear $LOAD_PATH.unshift("./lib") GetText::LocalePath.default_path_rules assert_equal($LOAD_PATH[0], "./lib") -- 1.8.4