Skip to content

Commit 2a837d0

Browse files
committed
Improved performance of numerical operations
1 parent 493cdad commit 2a837d0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/VBAexpressions.cls

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -812,11 +812,13 @@ End Function
812812

813813
Private Function CastOPtype(ByRef strOperand As String, ByRef Negate As Boolean) As Variant
814814
If strOperand <> vbNullString Then
815-
If IsLiteralString(strOperand) Then 'Literal strings like ['string']
816-
CastOPtype = FormatLiteralString(strOperand)
815+
Dim OpAscw As Long
816+
OpAscw = AscW(strOperand)
817+
If OpAscw < 58 And OpAscw > 45 Then
818+
CastOPtype = CDbl(strOperand)
817819
Else
818-
If AscW(strOperand) < 58 Then
819-
CastOPtype = CDbl(strOperand)
820+
If IsLiteralString(strOperand) Then 'Literal strings like ['string']
821+
CastOPtype = FormatLiteralString(strOperand)
820822
Else
821823
If Not Negate Then
822824
CastOPtype = -1 * CBool(strOperand)
@@ -2288,8 +2290,7 @@ Private Function NonZero(ParamArray values() As Variant) As Boolean
22882290
End Function
22892291

22902292
Private Function NotIsPI(ByRef VarName As String) As Boolean
2291-
2292-
NotIsPI = (LCase$(VarName) <> "pi")
2293+
NotIsPI = Not VarName Like "[Pp][Ii]"
22932294
End Function
22942295

22952296
Private Function OPsymbolInArgument(ByRef ArgDefStr As String, ByRef Pattrn As String) As Boolean

0 commit comments

Comments
 (0)