0023351: The use of 'if (A) {...} else if (A) {...}' pattern was detected.
authoromy <omy@opencascade.com>
Fri, 19 Oct 2012 14:09:57 +0000 (18:09 +0400)
committeromy <omy@opencascade.com>
Fri, 19 Oct 2012 14:09:57 +0000 (18:09 +0400)
Got rid of duplicated code.
Got rid of redundant conditions' checks in Standard_Integer TOPOC(Draw_Interpretor& interpretor,Standard_Integer na,const char** a) function.

src/TestTopOpe/TestTopOpe_BOOPCommands.cxx

index 91680e2..fef716c 100755 (executable)
@@ -85,14 +85,14 @@ Standard_Integer TOPOC(Draw_Interpretor& interpretor,Standard_Integer na,const c
       else if (!strcmp(a[1],"OUT")) sta = TopAbs_OUT;
       else if (!strcmp(a[1],"ON"))  sta = TopAbs_ON;
       
-      if (sta==TopAbs_IN||sta==TopAbs_OUT||sta == TopAbs_ON) {
+      if (sta != TopAbs_UNKNOWN) {
        if (na==2) { PBOOP->GetSplit(sta); } // tsp IN/ON/OUT
        else if ( na > 2 ) {
          TopAbs_ShapeEnum typ = TopAbs_SHAPE;
          if      (!strcmp(a[2],"e")) typ = TopAbs_EDGE;
          else if (!strcmp(a[2],"f")) typ = TopAbs_FACE;
          else if (!strcmp(a[2],"s")) typ = TopAbs_SOLID;
-         if (typ==TopAbs_EDGE||typ==TopAbs_FACE||typ==TopAbs_SOLID) {
+         if (typ != TopAbs_SHAPE) {
            if (na == 3) { 
              // tsp IN/ON/OUT e/f/s
              PBOOP->GetSplit(typ,sta);
@@ -107,10 +107,6 @@ Standard_Integer TOPOC(Draw_Interpretor& interpretor,Standard_Integer na,const c
            for(i=2;i<na;i++) PBOOP->GetSplit(sta,atoi(a[i])); 
          }
        }
-       else if ( na > 2 ) { 
-         // tsp IN/ON/OUT i1 i2 ...
-         for(i=2;i<na;i++) PBOOP->GetSplit(sta,atoi(a[i])); 
-       }
       }
       else { // tsp i1 i2 ...
        for (i = 1; i < na; i++) {
@@ -132,14 +128,14 @@ Standard_Integer TOPOC(Draw_Interpretor& interpretor,Standard_Integer na,const c
       else if (!strcmp(a[1],"OUT")) sta = TopAbs_OUT;
       else if (!strcmp(a[1],"ON"))  sta = TopAbs_ON;
       
-      if (sta==TopAbs_IN||sta==TopAbs_OUT||sta == TopAbs_ON) {
+      if (sta != TopAbs_UNKNOWN) {
        if (na==2) { PBOOP->GetMerged(sta); } // tme IN/ON/OUT
        else if ( na > 2 ) {
          TopAbs_ShapeEnum typ = TopAbs_SHAPE;
          if      (!strcmp(a[2],"e")) typ = TopAbs_EDGE;
          else if (!strcmp(a[2],"f")) typ = TopAbs_FACE;
          else if (!strcmp(a[2],"s")) typ = TopAbs_SOLID;
-         if (typ==TopAbs_EDGE||typ==TopAbs_FACE||typ==TopAbs_SOLID) {
+         if (typ != TopAbs_SHAPE) {
            if (na == 3) { 
              // tme IN/ON/OUT e/f/s
              PBOOP->GetMerged(typ,sta);
@@ -154,10 +150,6 @@ Standard_Integer TOPOC(Draw_Interpretor& interpretor,Standard_Integer na,const c
            for(i=2;i<na;i++) PBOOP->GetMerged(sta,atoi(a[i])); 
          }
        }
-       else if ( na > 2 ) { 
-         // tme IN/ON/OUT i1 i2 ...
-         for(i=2;i<na;i++) PBOOP->GetMerged(sta,atoi(a[i])); 
-       }
       }
       else { // tme i1 i2 ...
        for (i = 1; i < na; i++) {