diff options
| -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); } |
