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

ruby-changes:38744

From: nobu <ko1@a...>
Date: Thu, 11 Jun 2015 11:36:02 +0900 (JST)
Subject: [ruby-changes:38744] nobu:r50825 (trunk): vm_core.h: make VM_ASSERT an expression

nobu	2015-06-11 11:35:46 +0900 (Thu, 11 Jun 2015)

  New Revision: 50825

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

  Log:
    vm_core.h: make VM_ASSERT an expression
    
    * vm_core.h (VM_ASSERT): make an expression, as well as standard
      assert().

  Modified files:
    trunk/vm_core.h
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 50824)
+++ vm_core.h	(revision 50825)
@@ -21,11 +21,11 @@ https://github.com/ruby/ruby/blob/trunk/vm_core.h#L21
 #endif
 
 #if VM_CHECK_MODE > 0
-#define VM_ASSERT(expr) do { \
-    if(!(expr)) rb_bug("%s:%d assertion violation - %s", __FILE__, __LINE__, #expr); \
-} while (0)
+#define VM_ASSERT(expr) ( \
+	LIKELY(expr) ? (void)0 : \
+	rb_bug("%s:%d assertion violation - %s", __FILE__, __LINE__, #expr))
 #else
-#define VM_ASSERT(expr)
+#define VM_ASSERT(expr) ((void)0)
 #endif
 
 #define RUBY_VM_THREAD_MODEL 2

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

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