diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-10 14:10:19 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-10 14:10:19 +0000 |
commit | 1e8ec51e8fafc27f170241f93868528dd22861d4 (patch) | |
tree | f5a3e3367988621afdbfdfeb9d24a8e5b812b8d7 | |
parent | df033c0632fb59f6120d8d03dbcd371bf39a16ab (diff) | |
download | ruby-1e8ec51e8fafc27f170241f93868528dd22861d4.tar.gz |
* lib/pstore.rb (PStore::dump, PStore::load): allow subclass
overriding. [ruby-dev:34305]
* lib/yaml/store.rb (YAML::Store::marshal_dump_supports_canonical_option?):
add a method to support faster PStore.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | lib/pstore.rb | 19 | ||||
-rw-r--r-- | lib/yaml/store.rb | 4 |
3 files changed, 26 insertions, 5 deletions
@@ -1,3 +1,11 @@ +Thu Apr 10 23:08:52 2008 Yukihiro Matsumoto <matz@ruby-lang.org> + + * lib/pstore.rb (PStore::dump, PStore::load): allow subclass + overriding. [ruby-dev:34305] + + * lib/yaml/store.rb (YAML::Store::marshal_dump_supports_canonical_option?): + add a method to support faster PStore. + Thu Apr 10 20:36:45 2008 Akinori MUSHA <knu@iDaemons.org> * misc/rdebug.el, misc/README: Remove rdebug.el as per request diff --git a/lib/pstore.rb b/lib/pstore.rb index 2f94a045fd..54d4e7c3a6 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -399,7 +399,7 @@ class PStore def load_data(file, read_only) if read_only begin - table = Marshal.load(file) + table = load(file) if !table.is_a?(Hash) raise Error, "PStore file seems to be corrupted." end @@ -416,7 +416,7 @@ class PStore checksum = EMPTY_MARSHAL_CHECKSUM size = EMPTY_MARSHAL_DATA.size else - table = Marshal.load(data) + table = load(data) checksum = Digest::MD5.digest(data) size = data.size if !table.is_a?(Hash) @@ -461,7 +461,7 @@ class PStore if marshal_dump_supports_canonical_option? new_data = Marshal.dump(@table, -1, true) else - new_data = Marshal.dump(@table) + new_data = dump(@table) end new_checksum = Digest::MD5.digest(new_data) @@ -498,6 +498,19 @@ class PStore file.truncate(0) file.write(data) end + + + # This method is just a wrapped around Marshal.dump + # to allow subclass overriding used in YAML::Store. + def dump(table) # :nodoc: + Marshal::dump(table) + end + + # This method is just a wrapped around Marshal.load. + # to allow subclass overriding used in YAML::Store. + def load(content) # :nodoc: + Marshal::load(content) + end end # :enddoc: diff --git a/lib/yaml/store.rb b/lib/yaml/store.rb index 2ffa9554b9..4f0384cc5e 100644 --- a/lib/yaml/store.rb +++ b/lib/yaml/store.rb @@ -23,7 +23,7 @@ class YAML::Store < PStore YAML::load(content) end - def load_file(file) - YAML::load(file) + def marshal_dump_supports_canonical_option? + false end end |