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

ruby-changes:27546

From: nobu <ko1@a...>
Date: Tue, 5 Mar 2013 20:24:08 +0900 (JST)
Subject: [ruby-changes:27546] nobu:r39598 (trunk): intern.h: inline function rb_check_arity

nobu	2013-03-05 20:23:55 +0900 (Tue, 05 Mar 2013)

  New Revision: 39598

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

  Log:
    intern.h: inline function rb_check_arity
    
    * include/ruby/intern.h (rb_check_arity): make a static inline
      function so it can be used as an expression and argc would be
      evaulated only once.

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/intern.h

Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 39597)
+++ include/ruby/intern.h	(revision 39598)
@@ -266,10 +266,12 @@ const char *rb_sourcefile(void); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L266
 VALUE rb_check_funcall(VALUE, ID, int, VALUE*);
 
 NORETURN(void rb_error_arity(int, int, int));
-#define rb_check_arity(argc, min, max) do { \
-  if (((argc) < (min)) || ((argc) > (max) && (max) != UNLIMITED_ARGUMENTS)) \
-    rb_error_arity(argc, min, max); \
-  } while(0)
+static inline void
+rb_check_arity(int argc, int min, int max)
+{
+    if ((argc < min) || (max != UNLIMITED_ARGUMENTS && argc > max))
+	rb_error_arity(argc, min, max);
+}
 
 #if defined(NFDBITS) && defined(HAVE_RB_FD_INIT)
 typedef struct {
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39597)
+++ ChangeLog	(revision 39598)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Mar  5 20:23:54 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* include/ruby/intern.h (rb_check_arity): make a static inline
+	  function so it can be used as an expression and argc would be
+	  evaulated only once.
+
 Tue Mar  5 12:30:55 2013  Eric Hodel  <drbrain@s...>
 
 	* lib/rubygems.rb:  Bump version to 2.0.1 for upcoming bugfix release

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

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