From 8e3ee5a87ffbc4c1d0356d8f3b83cc7191229660 Mon Sep 17 00:00:00 2001 From: Jordan DeLong Date: Fri, 5 Jul 2013 19:02:40 -0700 Subject: [PATCH] Use stringToNumeric in tv_comparisons I like this api slightly better than passing in multiple output refs, but when I added I didn't change these so I could see perflabs separately. --- hphp/runtime/base/tv_comparisons.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/hphp/runtime/base/tv_comparisons.cpp b/hphp/runtime/base/tv_comparisons.cpp index 6169977db..8714e2717 100644 --- a/hphp/runtime/base/tv_comparisons.cpp +++ b/hphp/runtime/base/tv_comparisons.cpp @@ -70,13 +70,9 @@ bool cellRelOp(Op op, Cell cell, int64_t val) { case KindOfStaticString: case KindOfString: { - auto const sdata = cell.m_data.pstr; - int64_t ival; - double dval; - auto const dt = sdata->isNumericWithVal(ival, dval, - /* allow_error */ true); - return dt == KindOfInt64 ? op(ival, val) : - dt == KindOfDouble ? op(dval, val) : + auto const num = stringToNumeric(cell.m_data.pstr); + return num.m_type == KindOfInt64 ? op(num.m_data.num, val) : + num.m_type == KindOfDouble ? op(num.m_data.dbl, val) : op(0, val); } @@ -128,12 +124,9 @@ bool cellRelOp(Op op, Cell cell, const StringData* val) { case KindOfInt64: { - int64_t ival; - double dval; - auto const dt = val->isNumericWithVal(ival, dval, - /* allow_error */ true); - return dt == KindOfInt64 ? op(cell.m_data.num, ival) : - dt == KindOfDouble ? op(cell.m_data.num, dval) : + auto const num = stringToNumeric(val); + return num.m_type == KindOfInt64 ? op(cell.m_data.num, num.m_data.num) : + num.m_type == KindOfDouble ? op(cell.m_data.num, num.m_data.dbl) : op(cell.m_data.num, 0); }