From: omy Date: Fri, 19 Oct 2012 14:09:57 +0000 (+0400) Subject: 0023351: The use of 'if (A) {...} else if (A) {...}' pattern was detected. X-Git-Tag: V6_5_4~33 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=7da2a6ab87a79792cbc31e34f029b60e2e811662;p=occt-copy.git 0023351: The use of 'if (A) {...} else if (A) {...}' pattern was detected. 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. --- diff --git a/src/TestTopOpe/TestTopOpe_BOOPCommands.cxx b/src/TestTopOpe/TestTopOpe_BOOPCommands.cxx index 91680e2d60..fef716c421 100755 --- a/src/TestTopOpe/TestTopOpe_BOOPCommands.cxx +++ b/src/TestTopOpe/TestTopOpe_BOOPCommands.cxx @@ -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;iGetSplit(sta,atoi(a[i])); } } - else if ( na > 2 ) { - // tsp IN/ON/OUT i1 i2 ... - for(i=2;iGetSplit(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;iGetMerged(sta,atoi(a[i])); } } - else if ( na > 2 ) { - // tme IN/ON/OUT i1 i2 ... - for(i=2;iGetMerged(sta,atoi(a[i])); - } } else { // tme i1 i2 ... for (i = 1; i < na; i++) {