Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
Data Structures | Macros | Enumerations | Functions
compar.h File Reference

Internal header for Comparable. More...

#include "internal/vm.h"

Go to the source code of this file.

Data Structures

struct  cmp_opt_data
 

Macros

#define STRING_P(s)   (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)
 
#define NEW_CMP_OPT_MEMO(type, value)    NEW_PARTIAL_MEMO_FOR(type, value, cmp_opt)
 
#define CMP_OPTIMIZABLE_BIT(type)   (1U << TOKEN_PASTE(cmp_opt_,type))
 
#define CMP_OPTIMIZABLE(data, type)
 
#define OPTIMIZED_CMP(a, b, data)
 

Enumerations

enum  { cmp_opt_Integer , cmp_opt_String , cmp_opt_Float , cmp_optimizable_count }
 

Functions

VALUE rb_invcmp (VALUE, VALUE)
 

Detailed Description

Internal header for Comparable.

Author
Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Definition in file compar.h.

Macro Definition Documentation

◆ CMP_OPTIMIZABLE

#define CMP_OPTIMIZABLE (   data,
  type 
)
Value:
(((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))))
#define id_cmp
Definition: array.c:43
#define TOKEN_PASTE(x, y)
Definition: config.h:38
#define CMP_OPTIMIZABLE_BIT(type)
Definition: compar.h:30
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:56

Definition at line 31 of file compar.h.

◆ CMP_OPTIMIZABLE_BIT

#define CMP_OPTIMIZABLE_BIT (   type)    (1U << TOKEN_PASTE(cmp_opt_,type))

Definition at line 30 of file compar.h.

◆ NEW_CMP_OPT_MEMO

#define NEW_CMP_OPT_MEMO (   type,
  value 
)     NEW_PARTIAL_MEMO_FOR(type, value, cmp_opt)

Definition at line 28 of file compar.h.

◆ OPTIMIZED_CMP

#define OPTIMIZED_CMP (   a,
  b,
  data 
)
Value:
((FIXNUM_P(a) && FIXNUM_P(b) && CMP_OPTIMIZABLE(data, Integer)) ? \
(((long)a > (long)b) ? 1 : ((long)a < (long)b) ? -1 : 0) : \
(STRING_P(a) && STRING_P(b) && CMP_OPTIMIZABLE(data, String)) ? \
rb_str_cmp(a, b) : \
(RB_FLOAT_TYPE_P(a) && RB_FLOAT_TYPE_P(b) && CMP_OPTIMIZABLE(data, Float)) ? \
rb_float_cmp(a, b) : \
rb_cmpint(rb_funcallv(a, id_cmp, 1, &b), a, b))
int rb_str_cmp(VALUE, VALUE)
Definition: string.c:3378
#define STRING_P(s)
Definition: compar.h:14
#define CMP_OPTIMIZABLE(data, type)
Definition: compar.h:31
int rb_float_cmp(VALUE x, VALUE y)
Definition: numeric.c:1521
#define rb_funcallv(...)
Definition: internal.h:77
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
#define FIXNUM_P

Definition at line 38 of file compar.h.

◆ STRING_P

#define STRING_P (   s)    (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)

Definition at line 14 of file compar.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
cmp_opt_Integer 
cmp_opt_String 
cmp_opt_Float 
cmp_optimizable_count 

Definition at line 16 of file compar.h.

Function Documentation

◆ rb_invcmp()

VALUE rb_invcmp ( VALUE  x,
VALUE  y 
)

Definition at line 50 of file compar.c.

References INT2FIX, NIL_P, Qnil, Qundef, rb_cmpint, and rb_exec_recursive().