ruby-changes:12890
From: akr <ko1@a...>
Date: Sat, 22 Aug 2009 13:52:29 +0900 (JST)
Subject: [ruby-changes:12890] Ruby:r24625 (trunk): * ext/syck/rubyext.c (id_hash_new): new function to create a hash
akr 2009-08-22 13:52:09 +0900 (Sat, 22 Aug 2009) New Revision: 24625 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24625 Log: * 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. Modified files: trunk/ChangeLog trunk/ext/syck/rubyext.c trunk/lib/yaml.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 24624) +++ ChangeLog (revision 24625) @@ -1,3 +1,14 @@ +Sat Aug 22 13:46:15 2009 Tanaka Akira <akr@f...> + + * 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. + Sat Aug 22 13:05:22 2009 NARUSE, Yui <naruse@r...> * Makefile.in: use CP and MV macros. Index: lib/yaml.rb =================================================================== --- lib/yaml.rb (revision 24624) +++ lib/yaml.rb (revision 24625) @@ -384,10 +384,6 @@ else emitter.reset( opts ) end - oid = - case oid when Fixnum, NilClass; oid - else oid = "#{oid.object_id}-#{oid.hash}" - end out.emit( oid, &e ) end Index: ext/syck/rubyext.c =================================================================== --- ext/syck/rubyext.c (revision 24624) +++ ext/syck/rubyext.c (revision 24625) @@ -837,6 +837,15 @@ 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 @@ 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 @@ 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 @@ 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) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/