ruby-changes:4473
From: ko1@a...
Date: Thu, 10 Apr 2008 23:10:35 +0900 (JST)
Subject: [ruby-changes:4473] matz - Ruby:r15964 (trunk): * lib/pstore.rb (PStoRe: :dump, PStore::load): allow subclass
matz 2008-04-10 23:10:19 +0900 (Thu, 10 Apr 2008)
New Revision: 15964
Modified files:
trunk/ChangeLog
trunk/lib/pstore.rb
trunk/lib/yaml/store.rb
Log:
* 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.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15964&r2=15963&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/yaml/store.rb?r1=15964&r2=15963&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/pstore.rb?r1=15964&r2=15963&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15963)
+++ ChangeLog (revision 15964)
@@ -1,3 +1,11 @@
+Thu Apr 10 23:08:52 2008 Yukihiro Matsumoto <matz@r...>
+
+ * 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@i...>
* misc/rdebug.el, misc/README: Remove rdebug.el as per request
Index: lib/pstore.rb
===================================================================
--- lib/pstore.rb (revision 15963)
+++ lib/pstore.rb (revision 15964)
@@ -399,7 +399,7 @@
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 @@
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 @@
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 @@
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:
Index: lib/yaml/store.rb
===================================================================
--- lib/yaml/store.rb (revision 15963)
+++ lib/yaml/store.rb (revision 15964)
@@ -23,7 +23,7 @@
YAML::load(content)
end
- def load_file(file)
- YAML::load(file)
+ def marshal_dump_supports_canonical_option?
+ false
end
end
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/