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

ruby-changes:46172

From: nobu <ko1@a...>
Date: Sun, 9 Apr 2017 13:01:11 +0900 (JST)
Subject: [ruby-changes:46172] nobu:r58285 (trunk): special exception messages are static

nobu	2017-04-09 13:01:07 +0900 (Sun, 09 Apr 2017)

  New Revision: 58285

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

  Log:
    special exception messages are static
    
    * vm_core.h (rb_vm_register_special_exception): make the contents
      of special exception messages static.

  Modified files:
    trunk/vm.c
    trunk/vm_core.h
Index: vm.c
===================================================================
--- vm.c	(revision 58284)
+++ vm.c	(revision 58285)
@@ -2130,11 +2130,12 @@ rb_vm_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/vm.c#L2130
     RUBY_MARK_LEAVE("vm");
 }
 
+#undef rb_vm_register_special_exception
 void
-rb_vm_register_special_exception(enum ruby_special_exceptions sp, VALUE cls, const char *mesg)
+rb_vm_register_special_exception_str(enum ruby_special_exceptions sp, VALUE cls, VALUE mesg)
 {
     rb_vm_t *vm = GET_VM();
-    VALUE exc = rb_exc_new3(cls, rb_obj_freeze(rb_str_new2(mesg)));
+    VALUE exc = rb_exc_new3(cls, rb_obj_freeze(mesg));
     OBJ_TAINT(exc);
     OBJ_FREEZE(exc);
     ((VALUE *)vm->special_exceptions)[sp] = exc;
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 58284)
+++ vm_core.h	(revision 58285)
@@ -1466,7 +1466,10 @@ void ruby_thread_init_stack(rb_thread_t https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1466
 int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, ID *called_idp, VALUE *klassp);
 void rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
 
-void rb_vm_register_special_exception(enum ruby_special_exceptions sp, VALUE exception_class, const char *mesg);
+void rb_vm_register_special_exception_str(enum ruby_special_exceptions sp, VALUE exception_class, VALUE mesg);
+
+#define rb_vm_register_special_exception(sp, e, m) \
+    rb_vm_register_special_exception_str(sp, e, rb_usascii_str_new_static((m), (long)rb_strlen_lit(m)))
 
 void rb_gc_mark_machine_stack(rb_thread_t *th);
 

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

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