diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-05-17 11:28:56 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-05-17 21:03:12 +0200 |
commit | 649313625b94e6b879848fc19b607b74375100bf (patch) | |
tree | daa8993fe967cbfdad18aabac1635f7ded1977c2 /basic/source/comp | |
parent | 3a667101987ccbc75024942d779c8c62a4d0a296 (diff) |
New o3tl::temporary to simplify calls of std::modf
...that ignore the out-parameter integral part
Change-Id: I05f07c1a8909023232f8aecf75ea5541d4eb81ca
Reviewed-on: https://gerrit.libreoffice.org/54474
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'basic/source/comp')
-rw-r--r-- | basic/source/comp/exprnode.cxx | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx index 8d6db9bd88d8..aa8f69828c37 100644 --- a/basic/source/comp/exprnode.cxx +++ b/basic/source/comp/exprnode.cxx @@ -21,6 +21,7 @@ #include <math.h> #include <algorithm> +#include <o3tl/temporary.hxx> #include <rtl/math.hxx> #include <codegen.hxx> #include <parser.hxx> @@ -152,8 +153,7 @@ void SbiExprNode::ConvertToIntConstIfPossible() { if( eType >= SbxINTEGER && eType <= SbxDOUBLE ) { - double n; - if( nVal >= SbxMININT && nVal <= SbxMAXINT && modf( nVal, &n ) == 0 ) + if( nVal >= SbxMININT && nVal <= SbxMAXINT && modf( nVal, &o3tl::temporary(double()) ) == 0 ) { eType = SbxINTEGER; } @@ -220,9 +220,8 @@ void SbiExprNode::FoldConstants(SbiParser* pParser) // Potentially convolve in INTEGER (because of better opcode)? if( eType == SbxSINGLE || eType == SbxDOUBLE ) { - double x; if( nVal >= SbxMINLNG && nVal <= SbxMAXLNG - && !modf( nVal, &x ) ) + && !modf( nVal, &o3tl::temporary(double()) ) ) eType = SbxLONG; } if( eType == SbxLONG && nVal >= SbxMININT && nVal <= SbxMAXINT ) @@ -463,9 +462,8 @@ void SbiExprNode::FoldConstantsUnaryNode(SbiParser* pParser) // Potentially convolve in INTEGER (because of better opcode)? if( eType == SbxSINGLE || eType == SbxDOUBLE ) { - double x; if( nVal >= SbxMINLNG && nVal <= SbxMAXLNG - && !modf( nVal, &x ) ) + && !modf( nVal, &o3tl::temporary(double()) ) ) eType = SbxLONG; } if( eType == SbxLONG && nVal >= SbxMININT && nVal <= SbxMAXINT ) |