1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
matz 2009-05-27 16:31:51 +00:00
parent 80ad1473cf
commit 7afe0c92ea
2 changed files with 26 additions and 0 deletions

View file

@ -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,

View file

@ -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);
}