Skip to content

Commit 6cc5c7c

Browse files
authoredApr 25, 2020
Simplify how parseElement splits element string (#9726)
1 parent cee3c5e commit 6cc5c7c

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed
 

Diff for: ‎src/gui/guiFormSpecMenu.cpp

+4-16
Original file line numberDiff line numberDiff line change
@@ -2668,24 +2668,12 @@ void GUIFormSpecMenu::parseElement(parserData* data, const std::string &element)
26682668
if (parseVersionDirect(element))
26692669
return;
26702670

2671-
std::vector<std::string> parts = split(element,'[');
2672-
2673-
// ugly workaround to keep compatibility
2674-
if (parts.size() > 2) {
2675-
if (trim(parts[0]) == "image") {
2676-
for (unsigned int i=2;i< parts.size(); i++) {
2677-
parts[1] += "[" + parts[i];
2678-
}
2679-
}
2680-
else { return; }
2681-
}
2682-
2683-
if (parts.size() < 2) {
2671+
size_t pos = element.find('[');
2672+
if (pos == std::string::npos)
26842673
return;
2685-
}
26862674

2687-
std::string type = trim(parts[0]);
2688-
std::string description = trim(parts[1]);
2675+
std::string type = trim(element.substr(0, pos));
2676+
std::string description = element.substr(pos+1);
26892677

26902678
if (type == "container") {
26912679
parseContainer(data, description);

0 commit comments

Comments
 (0)
Please sign in to comment.