STYLE: simplify short-circuit involving autoPtr (#1775)

- with '&&' conditions, often better to check for non-null autoPtr
  first (it is cheap)

- check as bool instead of valid() method for cleaner code, especially
  when the wrapped item itself has a valid/empty or good.
  Also when handling multiple checks.

  Now
      if (ptr && ptr->valid())
      if (ptr1 || ptr2)

  instead
      if (ptr.valid() && ptr->valid())
      if (ptr1.valid() || ptr2.valid())
This commit is contained in:
Mark Olesen
2020-07-15 08:50:57 +02:00
parent 3baebcb101
commit 9af3f85cf9
35 changed files with 118 additions and 123 deletions

View File

@ -646,12 +646,12 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
if
(
CHFModel_.valid()
&& CHFSoobModel_.valid()
&& TDNBModel_.valid()
&& MHFModel_.valid()
&& LeidenfrostModel_.valid()
&& filmBoilingModel_.valid()
CHFModel_
&& CHFSoobModel_
&& TDNBModel_
&& MHFModel_
&& LeidenfrostModel_
&& filmBoilingModel_
)
{

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014-2018 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -106,7 +107,7 @@ Foam::BlendedInterfacialModel<ModelType>::evaluate
tmp<scalarGeoField> f1, f2;
if (model_.valid() || model1In2_.valid())
if (model_ || model1In2_)
{
f1 =
blendedInterfacialModel::interpolate<scalarGeoField>
@ -115,7 +116,7 @@ Foam::BlendedInterfacialModel<ModelType>::evaluate
);
}
if (model_.valid() || model2In1_.valid())
if (model_ || model2In1_)
{
f2 =
blendedInterfacialModel::interpolate<scalarGeoField>
@ -177,7 +178,7 @@ Foam::BlendedInterfacialModel<ModelType>::evaluate
if
(
correctFixedFluxBCs_
&& (model_.valid() || model1In2_.valid() || model2In1_.valid())
&& (model_ || model1In2_ || model2In1_)
)
{
correctFixedFluxBCs(x.ref());
@ -300,8 +301,8 @@ bool Foam::BlendedInterfacialModel<ModelType>::hasModel
{
return
&phase == &(phase1_)
? model1In2_.valid()
: model2In1_.valid();
? bool(model1In2_)
: bool(model2In1_);
}