From 6ad155dff3de175c480b8a8b91a10ab6e027a092 Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Fri, 13 Sep 2024 05:34:23 -0300 Subject: [PATCH] refactor(PD): reduce the number of comparisons --- src/Mod/PartDesign/App/FeatureHole.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index c55fec5bca..8cc6e47f0f 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -1700,15 +1700,17 @@ void Hole::onChanged(const App::Property* prop) } else if (prop == &DepthType) { std::string DepthMode(DepthType.getValueAsString()); - Depth.setReadOnly(DepthMode != "Dimension"); - DrillPoint.setReadOnly(DepthMode != "Dimension"); - DrillPointAngle.setReadOnly(DepthMode != "Dimension"); - DrillForDepth.setReadOnly(DepthMode != "Dimension"); + bool isNotDimension = (DepthMode != "Dimension"); + + Depth.setReadOnly(isNotDimension); + DrillPoint.setReadOnly(isNotDimension); + DrillPointAngle.setReadOnly(isNotDimension); + DrillForDepth.setReadOnly(isNotDimension); + if (!isRestoring()) { - if (DepthMode != "Dimension") { + if (isNotDimension) { // if through all, set the depth accordingly Depth.setValue(getThroughAllLength()); - // the thread depth is not dimension, it is the same as the hole depth ThreadDepth.setValue(getThroughAllLength()); } updateThreadDepthParam();