summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-04 09:11:05 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-04 09:11:05 +0000
commita227b16eba1cd836f12497d5b09f79dc6d89d6da (patch)
tree1706e2570eb64a58067b858b4544a1a5b687d452 /parse.y
parent535ee0197f5b820a9df2084270b6fbc0afb988a2 (diff)
* parse.y (must_be_dynamic_symbol): refactoring.
* add `inline'. * use UNLIKELY(). * check only DYNAMIC_SYM_P(), otherwise it is a bug. * lookup_id_str() is not needed in second condition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y23
1 files changed, 15 insertions, 8 deletions
diff --git a/parse.y b/parse.y
index 47899c196c..30e96d376d 100644
--- a/parse.y
+++ b/parse.y
@@ -10414,16 +10414,23 @@ sym_check_asciionly(VALUE str)
*/
static ID intern_str(VALUE str);
-static void
+static inline void
must_be_dynamic_symbol(VALUE x)
{
- st_data_t data;
- if (STATIC_SYM_P(x) && lookup_id_str(RSHIFT((unsigned long)(x),RUBY_SPECIAL_SHIFT), &data)) {
- rb_bug("wrong argument :%s (inappropriate Symbol)", RSTRING_PTR((VALUE)data));
- }
- if (SPECIAL_CONST_P(x) || BUILTIN_TYPE(x) != T_SYMBOL) {
- rb_bug("wrong argument type %s (expected Symbol)",
- rb_builtin_class_name(x));
+ if (UNLIKELY(DYNAMIC_SYM_P(x))) {
+ if (STATIC_SYM_P(x)) {
+ VALUE str;
+
+ if (lookup_id_str(RSHIFT((unsigned long)(x),RUBY_SPECIAL_SHIFT), (st_data_t *)&str)) {
+ rb_bug("wrong argument: %s (inappropriate Symbol)", RSTRING_PTR(str));
+ }
+ else {
+ rb_bug("wrong argument: inappropriate Symbol (%p)", (void *)x);
+ }
+ }
+ else {
+ rb_bug("wrong argument type %s (expected Symbol)", rb_builtin_class_name(x));
+ }
}
}