From 8c4ab4996901013aa41e8a169fb0c0fa98cca3c4 Mon Sep 17 00:00:00 2001 From: shugo Date: Thu, 7 Jan 2016 13:06:23 +0000 Subject: * 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 --- internal.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'internal.h') 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 */ -- cgit v1.2.3