[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:
@@ -159,13 +159,13 @@ void ViewProviderShapeBinder::highlightReferences(const bool on, bool /*auxiliar
|
||||
|
||||
for (std::string e : subs) {
|
||||
// Note: stoi may throw, but it strictly shouldn't happen
|
||||
if(e.substr(4) == "Edge") {
|
||||
if(e.compare(0, 4, "Edge") == 0) {
|
||||
int idx = std::stoi(e.substr(4)) - 1;
|
||||
assert ( idx>=0 );
|
||||
if ( idx < (ssize_t) lcolors.size() )
|
||||
lcolors[idx] = App::Color(1.0,0.0,1.0); // magenta
|
||||
}
|
||||
else if(e.substr(4) == "Face") {
|
||||
else if(e.compare(0, 4, "Face") == 0) {
|
||||
int idx = std::stoi(e.substr(4)) - 1;
|
||||
assert ( idx>=0 );
|
||||
if ( idx < (ssize_t) fcolors.size() )
|
||||
|
||||
Reference in New Issue
Block a user