aboutsummaryrefslogtreecommitdiffstats
path: root/encindex.h
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-29 05:10:06 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-29 05:10:06 +0000
commitbf968d25decb02f2bcfdd8d74c7af49a1ab47383 (patch)
tree1e702e8796e17507302ec5c552daf09ee1252944 /encindex.h
parent5cb3ea15aed77eb1c3db3b05d70139bbf7870972 (diff)
downloadruby-bf968d25decb02f2bcfdd8d74c7af49a1ab47383.tar.gz
* gc.c (gc_mark_ptr): remove debug code for #11244.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encindex.h')
-rw-r--r--encindex.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/encindex.h b/encindex.h
index dcb1646f3a..0527259c27 100644
--- a/encindex.h
+++ b/encindex.h
@@ -57,6 +57,28 @@ enum ruby_preserved_encindex {
#define rb_utf8_encindex() RUBY_ENCINDEX_UTF_8
#define rb_usascii_encindex() RUBY_ENCINDEX_US_ASCII
+#ifdef RUBY_ENCODING_H
+#define ENC_INDEX_MASK (~(~0U<<24))
+#define ENC_TO_ENCINDEX(enc) (int)((enc)->ruby_encoding_index & ENC_INDEX_MASK)
+
+static inline int
+enc_to_index(rb_encoding *enc)
+{
+ return enc ? ENC_TO_ENCINDEX(enc) : 0;
+}
+
+static inline int
+str_enc_get_index(VALUE str)
+{
+ int i = ENCODING_GET_INLINED(str);
+ if (i == ENCODING_INLINE_MAX) {
+ VALUE iv = rb_ivar_get(str, rb_id_encoding());
+ i = NUM2INT(iv);
+ }
+ return i;
+}
+#endif
+
#if defined(__cplusplus)
#if 0
{ /* satisfy cc-mode */