diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-08-05 12:52:19 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-08-05 12:52:19 +0100 |
commit | 2ef69e79492a47704eed0faa01351ba88a4e6605 (patch) | |
tree | a2d7d854d98b30aae73474ba856c1c56ada01961 | |
parent | Refactor JsonSerializer::ModelTreeIterateRoot with no pointer copy (diff) | |
download | slicer-2ef69e79492a47704eed0faa01351ba88a4e6605.tar.bz2 slicer-2ef69e79492a47704eed0faa01351ba88a4e6605.tar.xz slicer-2ef69e79492a47704eed0faa01351ba88a4e6605.zip |
Refactor XmlSerializer::ModelTreeProcessElement with no pointer copy
-rw-r--r-- | slicer/xml/serializer.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/slicer/xml/serializer.cpp b/slicer/xml/serializer.cpp index 1ffa897..acbb83d 100644 --- a/slicer/xml/serializer.cpp +++ b/slicer/xml/serializer.cpp @@ -407,16 +407,19 @@ namespace Slicer { mp->GetValue(XmlContentValueTarget(cec)); } else if (mp->HasValue()) { - auto typeIdPropName = mp->GetTypeIdProperty(); - auto typeId = mp->GetTypeId(); - auto element = cec.get(); - if (typeId && typeIdPropName) { - element->set_attribute(*typeIdPropName, *typeId); - mp = mp->GetSubclassModelPart(*typeId); + auto oec = [element = cec.get(), &ec](const auto & lmp) { + lmp->OnEachChild([element, &ec](auto && PH1, auto && PH2, auto && PH3) { + return XmlSerializer::ModelTreeIterate(element, PH1, PH2, PH3, ec); + }); + return element; + }; + if (auto typeIdPropName = mp->GetTypeIdProperty()) { + if (auto typeId = mp->GetTypeId()) { + oec(mp->GetSubclassModelPart(*typeId))->set_attribute(*typeIdPropName, *typeId); + return; + } } - mp->OnEachChild([element, ec](auto && PH1, auto && PH2, auto && PH3) { - return XmlSerializer::ModelTreeIterate(element, PH1, PH2, PH3, ec); - }); + oec(mp); } } |