Forráskód Böngészése

Merge pull request #4097 from ghalliday/issue8928

HPCC-8928 Optimize a few minor uses of NOT(expression)

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 12 éve
szülő
commit
78a39a9a08
3 módosított fájl, 29 hozzáadás és 3 törlés
  1. 1 1
      ecl/hql/hqlexpr.cpp
  2. 4 2
      ecl/hqlcpp/hqlcpp.cpp
  3. 24 0
      ecl/regress/boolcast2.ecl

+ 1 - 1
ecl/hql/hqlexpr.cpp

@@ -2919,7 +2919,7 @@ IHqlExpression * ensureExprType(IHqlExpression * expr, ITypeInfo * type, node_op
     }
 
     //MORE: Casts of datasets should create a dataset - but there is no parameter to determine the type from...
-    switch (type->getTypeCode())
+    switch (tc)
     {
     case type_table:
     case type_groupedtable:

+ 4 - 2
ecl/hqlcpp/hqlcpp.cpp

@@ -4764,7 +4764,7 @@ void HqlCppTranslator::doBuildFilterToTarget(BuildCtx & ctx, const CHqlBoundTarg
 {
     LinkedHqlExpr test = isOk.expr;
     if (invert)
-        test.setown(createValue(no_not, makeBoolType(), LINK(test)));
+        test.setown(getInverse(test));
 
     unsigned max = conds.ordinality();
     unsigned curIndex = 0;
@@ -7611,7 +7611,9 @@ void HqlCppTranslator::doBuildAssignAll(BuildCtx & ctx, const CHqlBoundTarget &
 void HqlCppTranslator::doBuildExprNot(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt)
 {
     assertex(expr->queryChild(0)->isBoolean());
-    doBuildPureSubExpr(ctx, expr, tgt);
+    CHqlBoundExpr bound;
+    buildExpr(ctx, expr->queryChild(0), bound);
+    tgt.expr.set(getInverse(bound.expr));
 }
 
 

+ 24 - 0
ecl/regress/boolcast2.ecl

@@ -0,0 +1,24 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2013 HPCC Systems.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+############################################################################## */
+
+integer x1 := 10 : stored('x1');
+decimal10_3 x2 := 10.0D : stored('x2');
+string10 x3 := 'x' : stored('x3');
+
+output((boolean)x1);
+output((boolean)x2);
+output((boolean)x3);