1#ifndef INTERNAL_COMPAR_H
2#define INTERNAL_COMPAR_H
11#include "internal/basic_operators.h"
13#define STRING_P(s) (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)
15#define CMP_OPTIMIZABLE(type) BASIC_OP_UNREDEFINED_P(BOP_CMP, type##_REDEFINED_OP_FLAG)
17#define OPTIMIZED_CMP(a, b) \
18 ((FIXNUM_P(a) && FIXNUM_P(b) && CMP_OPTIMIZABLE(INTEGER)) ? \
19 (((long)a > (long)b) ? 1 : ((long)a < (long)b) ? -1 : 0) : \
20 (STRING_P(a) && STRING_P(b) && CMP_OPTIMIZABLE(STRING)) ? \
22 (RB_FLOAT_TYPE_P(a) && RB_FLOAT_TYPE_P(b) && CMP_OPTIMIZABLE(FLOAT)) ? \
23 rb_float_cmp(a, b) : \
24 rb_cmpint(rb_funcallv(a, id_cmp, 1, &b), a, b))
uintptr_t VALUE
Type that represents a Ruby object.