summaryrefslogtreecommitdiff
path: root/symbol.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-30 04:44:39 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-30 04:44:39 (GMT)
commit51964bf995b7f3b0c1202646fc619b91e052f648 (patch)
tree9e921e2b346969ea7e66126e17f996e04fb1611a /symbol.c
parent23ce0a421d51110ac20db998c2f411b9eb290b5b (diff)
symbol.c: rb_sym_intern
* symbol.c (rb_sym_intern): rename from rb_cstr_intern and add variants. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'symbol.c')
-rw-r--r--symbol.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/symbol.c b/symbol.c
index 65ffab0..8e3e0c3 100644
--- a/symbol.c
+++ b/symbol.c
@@ -1014,14 +1014,43 @@ rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc)
return Qnil;
}
+#undef rb_sym_intern_cstr
+#undef rb_sym_intern_ascii_cstr
+#ifdef __clang__
+NOINLINE(VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc));
+#else
+FUNC_MINIMIZED(VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc));
+FUNC_MINIMIZED(VALUE rb_sym_intern_cstr(const char *ptr, rb_encoding *enc));
+FUNC_MINIMIZED(VALUE rb_sym_intern_ascii(const char *ptr, long len));
+FUNC_MINIMIZED(VALUE rb_sym_intern_ascii_cstr(const char *ptr));
+#endif
+
VALUE
-rb_cstr_intern(const char *ptr, long len, rb_encoding *enc)
+rb_sym_intern(const char *ptr, long len, rb_encoding *enc)
{
struct RString fake_str;
const VALUE name = rb_setup_fake_str(&fake_str, ptr, len, enc);
return rb_str_intern(name);
}
+VALUE
+rb_sym_intern_cstr(const char *ptr, rb_encoding *enc)
+{
+ return rb_sym_intern(ptr, strlen(ptr), enc);
+}
+
+VALUE
+rb_sym_intern_ascii(const char *ptr, long len)
+{
+ return rb_sym_intern(ptr, len, rb_usascii_encoding());
+}
+
+VALUE
+rb_sym_intern_ascii_cstr(const char *ptr)
+{
+ return rb_sym_intern_ascii(ptr, strlen(ptr));
+}
+
static ID
attrsetname_to_attr_id(VALUE name)
{