aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--include/ruby/intern.h10
2 files changed, 12 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 46a4777f6a..0de1d664ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Mar 5 20:23:54 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@segment7.net>
* lib/rubygems.rb: Bump version to 2.0.1 for upcoming bugfix release
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 5ff17a4971..063c5d059e 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -266,10 +266,12 @@ const char *rb_sourcefile(void);
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 {