aboutsummaryrefslogtreecommitdiffstats
path: root/internal.h
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-07 13:06:23 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-07 13:06:23 +0000
commit9f44b77a18d4d6099174c6044261eb1611a147ea (patch)
tree4d218c733f53d9c2fd9d53ad8a43d8a2080b0c08 /internal.h
parenta1115a1b4758900790e9cb4f36a4dccf3e2149b8 (diff)
downloadruby-9f44b77a18d4d6099174c6044261eb1611a147ea.tar.gz
* enum.c (enum_minmax): optimize object comparison in
Enumerable#minmax. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'internal.h')
-rw-r--r--internal.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal.h b/internal.h
index 95068ac0cd..5622998ff8 100644
--- a/internal.h
+++ b/internal.h
@@ -633,6 +633,22 @@ struct MEMO {
#define NEW_MEMO_FOR(type, value) \
((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))
+#define STRING_P(s) (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)
+
+enum {
+ cmp_opt_Fixnum,
+ cmp_opt_String,
+ cmp_optimizable_count
+};
+
+#define CMP_OPTIMIZABLE_BIT(type) (1U << TOKEN_PASTE(cmp_opt_,type))
+#define CMP_OPTIMIZABLE(data, type) \
+ (((data)->opt_inited & CMP_OPTIMIZABLE_BIT(type)) ? \
+ ((data)->opt_methods & CMP_OPTIMIZABLE_BIT(type)) : \
+ (((data)->opt_inited |= CMP_OPTIMIZABLE_BIT(type)), \
+ rb_method_basic_definition_p(TOKEN_PASTE(rb_c,type), id_cmp) && \
+ ((data)->opt_methods |= CMP_OPTIMIZABLE_BIT(type))))
+
/* ment is in method.h */
/* global variable */