diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-27 16:31:51 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-27 16:31:51 +0000 |
commit | c444004d8b67e1714bc8b6b9c40c54650e3e9221 (patch) | |
tree | c84bdb937845277ac26b3d084756779c7f864dcd | |
parent | 8e5f90fa969ea74da4044ebca9a5325ac5a5d11d (diff) | |
download | ruby-c444004d8b67e1714bc8b6b9c40c54650e3e9221.tar.gz ruby-c444004d8b67e1714bc8b6b9c40c54650e3e9221.tar.xz ruby-c444004d8b67e1714bc8b6b9c40c54650e3e9221.zip |
* marshal.c (w_encoding): more compact encoding information for
US-ASCII and UTF-8. [incompatible] [experimental]
* marshal.c (r_ivar): restore :E encoding information.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | marshal.c | 19 |
2 files changed, 26 insertions, 0 deletions
@@ -13,6 +13,13 @@ Wed May 27 18:00:15 2009 Yukihiro Matsumoto <matz@ruby-lang.org> * bignum.c (bigand_int): even less object allocation. +Wed May 27 14:29:55 2009 Yukihiro Matsumoto <matz@ruby-lang.org> + + * marshal.c (w_encoding): more compact encoding information for + US-ASCII and UTF-8. [incompatible] [experimental] + + * marshal.c (r_ivar): restore :E encoding information. + Wed May 27 14:08:39 2009 Yukihiro Matsumoto <matz@ruby-lang.org> * st.c (st_insert2): new function with processing new key, @@ -471,6 +471,7 @@ static int w_obj_each(ID id, VALUE value, struct dump_call_arg *arg) { if (id == rb_id_encoding()) return ST_CONTINUE; + if (id == rb_intern("E")) return ST_CONTINUE; w_symbol(id, arg->arg); w_object(value, arg->arg, arg->limit); return ST_CONTINUE; @@ -488,6 +489,19 @@ w_encoding(VALUE obj, long num, struct dump_call_arg *arg) return; } w_long(num + 1, arg->arg); + + /* special treatment for US-ASCII and UTF-8 */ + if (encidx == rb_usascii_encindex()) { + w_symbol(rb_intern("E"), arg->arg); + w_object(Qfalse, arg->arg, arg->limit); + return; + } + else if (encidx == rb_utf8_encindex()) { + w_symbol(rb_intern("E"), arg->arg); + w_object(Qtrue, arg->arg, arg->limit); + return; + } + w_symbol(rb_id_encoding(), arg->arg); do { if (!arg->arg->encodings) @@ -1152,6 +1166,11 @@ r_ivar(VALUE obj, struct load_arg *arg) int idx = rb_enc_find_index(StringValueCStr(val)); if (idx > 0) rb_enc_associate_index(obj, idx); } + if (id == rb_intern("E")) { + if (val == Qfalse) rb_enc_associate_index(obj, rb_usascii_encindex()); + else if (val == Qtrue) rb_enc_associate_index(obj, rb_utf8_encindex()); + /* bogus ignore */ + } else { rb_ivar_set(obj, id, val); } |