Commit b796c503 authored by mirichi's avatar mirichi

OP_EQ系が速くなった

parent 5138f62d
......@@ -1888,34 +1888,33 @@ RETRY_TRY_BLOCK:
NEXT;
}
#define OP_CMP_BODY(op,v1,v2) do {\
if (regs[a].v1 op regs[a+1].v2) {\
SET_TRUE_VALUE(regs[a]);\
}\
else {\
SET_FALSE_VALUE(regs[a]);\
}\
} while(0)
#define OP_CMP_BODY(op,v1,v2) (regs[a].v1 op regs[a+1].v2)
#define OP_CMP(op) do {\
int a = GETARG_A(i);\
int result;\
/* need to check if - is overridden */\
switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\
case TYPES2(MRB_TT_FIXNUM,MRB_TT_FIXNUM):\
OP_CMP_BODY(op,attr_i,attr_i);\
result = OP_CMP_BODY(op,attr_i,attr_i);\
break;\
case TYPES2(MRB_TT_FIXNUM,MRB_TT_FLOAT):\
OP_CMP_BODY(op,attr_i,attr_f);\
result = OP_CMP_BODY(op,attr_i,attr_f);\
break;\
case TYPES2(MRB_TT_FLOAT,MRB_TT_FIXNUM):\
OP_CMP_BODY(op,attr_f,attr_i);\
result = OP_CMP_BODY(op,attr_f,attr_i);\
break;\
case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\
OP_CMP_BODY(op,attr_f,attr_f);\
result = OP_CMP_BODY(op,attr_f,attr_f);\
break;\
default:\
goto L_SEND;\
}\
if (result) {\
SET_TRUE_VALUE(regs[a]);\
}\
else {\
SET_FALSE_VALUE(regs[a]);\
}\
} while(0)
CASE(OP_EQ) {
......@@ -1932,24 +1931,28 @@ RETRY_TRY_BLOCK:
CASE(OP_LT) {
/* A B C R(A) := R(A)<R(A+1) (Syms[B]=:<,C=1)*/
int a = GETARG_A(i);
OP_CMP(<);
NEXT;
}
CASE(OP_LE) {
/* A B C R(A) := R(A)<=R(A+1) (Syms[B]=:<=,C=1)*/
int a = GETARG_A(i);
OP_CMP(<=);
NEXT;
}
CASE(OP_GT) {
/* A B C R(A) := R(A)<R(A+1) (Syms[B]=:<,C=1)*/
int a = GETARG_A(i);
OP_CMP(>);
NEXT;
}
CASE(OP_GE) {
/* A B C R(A) := R(A)<=R(A+1) (Syms[B]=:<=,C=1)*/
int a = GETARG_A(i);
OP_CMP(>=);
NEXT;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment