[前][次][番号順一覧][スレッド一覧]

ruby-changes:54394

From: nobu <ko1@a...>
Date: Fri, 28 Dec 2018 19:33:08 +0900 (JST)
Subject: [ruby-changes:54394] nobu:r66608 (trunk): Hoisted out undefined_constant

nobu	2018-12-28 19:33:02 +0900 (Fri, 28 Dec 2018)

  New Revision: 66608

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66608

  Log:
    Hoisted out undefined_constant

  Modified files:
    trunk/variable.c
Index: variable.c
===================================================================
--- variable.c	(revision 66607)
+++ variable.c	(revision 66608)
@@ -2566,6 +2566,14 @@ rb_public_const_get_at(VALUE klass, ID i https://github.com/ruby/ruby/blob/trunk/variable.c#L2566
     return rb_const_get_0(klass, id, TRUE, FALSE, TRUE);
 }
 
+NORETURN(static void undefined_constant(VALUE mod, VALUE name));
+static void
+undefined_constant(VALUE mod, VALUE name)
+{
+    rb_name_err_raise("constant %2$s::%1$s not defined",
+                      mod, name);
+}
+
 /*
  *  call-seq:
  *     remove_const(sym)   -> obj
@@ -2582,8 +2590,7 @@ rb_mod_remove_const(VALUE mod, VALUE nam https://github.com/ruby/ruby/blob/trunk/variable.c#L2590
     const ID id = id_for_var(mod, name, a, constant);
 
     if (!id) {
-	rb_name_err_raise("constant %2$s::%1$s not defined",
-			  mod, name);
+        undefined_constant(mod, name);
     }
     return rb_const_remove(mod, id);
 }
@@ -2601,8 +2608,7 @@ rb_const_remove(VALUE mod, ID id) https://github.com/ruby/ruby/blob/trunk/variable.c#L2608
 	    rb_name_err_raise("cannot remove %2$s::%1$s",
 			      mod, ID2SYM(id));
 	}
-	rb_name_err_raise("constant %2$s::%1$s not defined",
-			  mod, ID2SYM(id));
+        undefined_constant(mod, ID2SYM(id));
     }
 
     rb_clear_constant_cache();
@@ -2988,8 +2994,7 @@ set_const_visibility(VALUE mod, int argc https://github.com/ruby/ruby/blob/trunk/variable.c#L2994
 		rb_clear_constant_cache();
 	    }
 
-	    rb_name_err_raise("constant %2$s::%1$s not defined",
-			      mod, val);
+            undefined_constant(mod, val);
 	}
 	if ((ce = rb_const_lookup(mod, id))) {
 	    ce->flag &= ~mask;
@@ -3008,8 +3013,7 @@ set_const_visibility(VALUE mod, int argc https://github.com/ruby/ruby/blob/trunk/variable.c#L3013
 	    if (i > 0) {
 		rb_clear_constant_cache();
 	    }
-	    rb_name_err_raise("constant %2$s::%1$s not defined",
-			      mod, ID2SYM(id));
+            undefined_constant(mod, ID2SYM(id));
 	}
     }
     rb_clear_constant_cache();
@@ -3023,10 +3027,11 @@ rb_deprecate_constant(VALUE mod, const c https://github.com/ruby/ruby/blob/trunk/variable.c#L3027
     long len = strlen(name);
 
     rb_class_modify_check(mod);
-    if (!(id = rb_check_id_cstr(name, len, NULL)) ||
-	!(ce = rb_const_lookup(mod, id))) {
-	rb_name_err_raise("constant %2$s::%1$s not defined",
-			  mod, rb_fstring_new(name, len));
+    if (!(id = rb_check_id_cstr(name, len, NULL))) {
+	undefined_constant(mod, rb_fstring_new(name, len));
+    }
+    if (!(ce = rb_const_lookup(mod, id))) {
+        undefined_constant(mod, ID2SYM(id));
     }
     ce->flag |= CONST_DEPRECATED;
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]