From cc42afc14b6e54750a95b0e5fd7f01664280c36e Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 20 Dec 2017 19:05:00 +0000 Subject: Combine operator< and ByteString::Compare(). Fix or optimize some ByteString::Compare() callers. Change-Id: I0fde91afc3d17fe160b46d00a441ad05e56377e7 Reviewed-on: https://pdfium-review.googlesource.com/20851 Reviewed-by: Henrique Nakashima Commit-Queue: Lei Zhang --- fxjs/cfxjse_formcalc_context.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'fxjs') diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp index b02e5a9d41..f9d130a119 100644 --- a/fxjs/cfxjse_formcalc_context.cpp +++ b/fxjs/cfxjse_formcalc_context.cpp @@ -4976,9 +4976,9 @@ void CFXJSE_FormCalcContext::less_operator(CFXJSE_Value* pThis, } if (argFirst->IsString() && argSecond->IsString()) { - args.GetReturnValue()->SetInteger( - argFirst->ToString().Compare(argSecond->ToString().AsStringView()) == - -1); + int result = + argFirst->ToString().Compare(argSecond->ToString().AsStringView()) < 0; + args.GetReturnValue()->SetInteger(result); return; } @@ -5006,9 +5006,9 @@ void CFXJSE_FormCalcContext::lessequal_operator( } if (argFirst->IsString() && argSecond->IsString()) { - args.GetReturnValue()->SetInteger( - argFirst->ToString().Compare(argSecond->ToString().AsStringView()) != - 1); + int result = + argFirst->ToString().Compare(argSecond->ToString().AsStringView()) <= 0; + args.GetReturnValue()->SetInteger(result); return; } @@ -5034,9 +5034,9 @@ void CFXJSE_FormCalcContext::greater_operator(CFXJSE_Value* pThis, } if (argFirst->IsString() && argSecond->IsString()) { - args.GetReturnValue()->SetInteger( - argFirst->ToString().Compare(argSecond->ToString().AsStringView()) == - 1); + int result = + argFirst->ToString().Compare(argSecond->ToString().AsStringView()) > 0; + args.GetReturnValue()->SetInteger(result); return; } @@ -5064,9 +5064,9 @@ void CFXJSE_FormCalcContext::greaterequal_operator( } if (argFirst->IsString() && argSecond->IsString()) { - args.GetReturnValue()->SetInteger( - argFirst->ToString().Compare(argSecond->ToString().AsStringView()) != - -1); + int result = + argFirst->ToString().Compare(argSecond->ToString().AsStringView()) >= 0; + args.GetReturnValue()->SetInteger(result); return; } -- cgit v1.2.3