summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-22 04:52:09 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-22 04:52:09 +0000
commitdfc3fccef31ace6f26ac96388a441b668abf092d (patch)
tree1cde2518f895575e44fb57bc50762db38df1cb07 /ext
parent0570b9969bf2e43c96346471116f5eb0a4806c88 (diff)
* ext/syck/rubyext.c (id_hash_new): new function to create a hash
which key is compared by object id. (syck_parser_load): use id_hash_new for bonus->data. (syck_parser_load_documents): ditto. (syck_emitter_reset): ditto. * lib/yaml.rb (YAML.quick_emit): give the object itself to eimitter. don't use object_id and hash. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/syck/rubyext.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c
index 3538deb5e3..5b056f8e02 100644
--- a/ext/syck/rubyext.c
+++ b/ext/syck/rubyext.c
@@ -837,6 +837,15 @@ syck_parser_bufsize_get(VALUE self)
return INT2FIX( parser->bufsize );
}
+static VALUE
+id_hash_new(void)
+{
+ VALUE hash;
+ hash = rb_hash_new();
+ rb_funcall(hash, rb_intern("compare_by_identity"), 0);
+ return hash;
+}
+
/*
* YAML::Syck::Parser.load( IO or String )
*/
@@ -856,7 +865,7 @@ syck_parser_load(int argc, VALUE *argv, VALUE self)
bonus = (struct parser_xtra *)parser->bonus;
bonus->taint = syck_parser_assign_io(parser, &port);
- bonus->data = rb_hash_new();
+ bonus->data = id_hash_new();
bonus->resolver = rb_attr_get( self, s_resolver );
if ( NIL_P( proc ) ) bonus->proc = 0;
else bonus->proc = proc;
@@ -889,7 +898,7 @@ syck_parser_load_documents(int argc, VALUE *argv, VALUE self)
while ( 1 )
{
/* Reset hash for tracking nodes */
- bonus->data = rb_hash_new();
+ bonus->data = id_hash_new();
/* Parse a document */
v = syck_parse( parser );
@@ -1953,7 +1962,7 @@ syck_emitter_reset(int argc, VALUE *argv, VALUE self)
bonus->oid = Qnil;
bonus->port = rb_str_new2( "" );
- bonus->data = rb_hash_new();
+ bonus->data = id_hash_new();
if (rb_scan_args(argc, argv, "01", &options) == 0)
{