summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-29 05:30:50 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-29 05:30:50 +0000
commit56eee285be2e18f727ef15d58e338b134c3ab210 (patch)
treeaed87dd85181c76b099fc5c620ac1606f65f09c8 /encoding.c
parent106f033b89fed268fe376ebaf16cb95fda655e6a (diff)
revert r52336 (commit miss)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/encoding.c b/encoding.c
index 0444b5fccb..57c89ee8ce 100644
--- a/encoding.c
+++ b/encoding.c
@@ -52,7 +52,9 @@ static struct {
} enc_table;
#define ENC_DUMMY_FLAG (1<<24)
+#define ENC_INDEX_MASK (~(~0U<<24))
+#define ENC_TO_ENCINDEX(enc) (int)((enc)->ruby_encoding_index & ENC_INDEX_MASK)
#define ENC_DUMMY_P(enc) ((enc)->ruby_encoding_index & ENC_DUMMY_FLAG)
#define ENC_SET_DUMMY(enc) ((enc)->ruby_encoding_index |= ENC_DUMMY_FLAG)
@@ -110,7 +112,7 @@ rb_enc_from_encoding(rb_encoding *encoding)
int
rb_enc_to_index(rb_encoding *enc)
{
- return enc_to_index(enc);
+ return enc ? ENC_TO_ENCINDEX(enc) : 0;
}
int
@@ -756,7 +758,13 @@ rb_enc_get_index(VALUE obj)
default:
case T_STRING:
case T_REGEXP:
- i = str_enc_get_index(obj);
+ i = ENCODING_GET_INLINED(obj);
+ if (i == ENCODING_INLINE_MAX) {
+ VALUE iv;
+
+ iv = rb_ivar_get(obj, rb_id_encoding());
+ i = NUM2INT(iv);
+ }
break;
case T_FILE:
tmp = rb_funcallv(obj, rb_intern("internal_encoding"), 0, 0);