[PD] Use compare to compare strings instead of substr
Used when finding subelements of a feature. Many of the comparisons used to also check for string lengths, but as far as I can tell they are not strictly necessary (see https://www.cplusplus.com/reference/string/string/substr/) and just `substr` can be used without them. However, `compare` explicitly is for comparing, and does not make a new object that `substr` does.
This commit is contained in:
@@ -98,12 +98,12 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
|
||||
axis = refSketch->getAxis(Part::Part2DObject::V_Axis);
|
||||
else if (subStrings[0] == "N_Axis")
|
||||
axis = refSketch->getAxis(Part::Part2DObject::N_Axis);
|
||||
else if (subStrings[0].size() > 4 && subStrings[0].substr(0,4) == "Axis") {
|
||||
else if (subStrings[0].compare(0, 4, "Axis") == 0) {
|
||||
int AxId = std::atoi(subStrings[0].substr(4,4000).c_str());
|
||||
if (AxId >= 0 && AxId < refSketch->getAxisCount())
|
||||
axis = refSketch->getAxis(AxId);
|
||||
}
|
||||
else if (subStrings[0].substr(0,4) == "Edge") {
|
||||
else if (subStrings[0].compare(0, 4, "Edge") == 0) {
|
||||
Part::TopoShape refShape = refSketch->Shape.getShape();
|
||||
TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str());
|
||||
TopoDS_Edge refEdge = TopoDS::Edge(ref);
|
||||
|
||||
Reference in New Issue
Block a user