MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / optimize

Method optimize

Engine/source/console/optimizer.cpp:47–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47bool FloatBinaryExprNode::optimize()
48{
49 // Perform constant folding
50 if (isLiteralNumber(right) && isLiteralNumber(left))
51 {
52 F64 rightValue = getFloatValue(right);
53 F64 leftValue = getFloatValue(left);
54 F64 result = 0.0;
55
56 switch (op)
57 {
58 case '+':
59 result = leftValue + rightValue;
60 break;
61 case '-':
62 result = leftValue - rightValue;
63 break;
64 case '*':
65 result = leftValue * rightValue;
66 break;
67 case '/':
68 if (rightValue != 0.0)
69 result = leftValue / rightValue;
70 break;
71 }
72
73 optimizedNode = FloatNode::alloc(dbgLineNumber, result);
74 return true;
75 }
76
77 return false;
78}
79
80bool IntBinaryExprNode::optimize()
81{

Callers

nothing calls this directly

Calls 5

isLiteralNumberFunction · 0.85
getFloatValueFunction · 0.85
allocFunction · 0.85
getIntValueFunction · 0.85
getExprNodeNameEnumMethod · 0.45

Tested by

no test coverage detected