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 | 7afe0c92ea9f4e363429f3209567b4bc3de302db (patch) | |
tree | c84bdb937845277ac26b3d084756779c7f864dcd /marshal.c | |
parent | 80ad1473cfefea77b4964d285fcae8ff5a4cac4b (diff) | |
download | ruby-7afe0c92ea9f4e363429f3209567b4bc3de302db.tar.gz |
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@23597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'marshal.c')
-rw-r--r-- | marshal.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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); } |