mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -346,14 +346,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Load a single file, or load and combine multiple selected files
|
||||
autoPtr<triSurface> surfPtr = loader.load(loadingOption, scaleFactor);
|
||||
if (!surfPtr.valid() || surfPtr().empty())
|
||||
if (!surfPtr || surfPtr->empty())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Problem loading surface(s) for entry: "
|
||||
<< dictName << exit(FatalError);
|
||||
}
|
||||
|
||||
triSurface surf = surfPtr();
|
||||
triSurface surf = *surfPtr;
|
||||
|
||||
Info<< nl
|
||||
<< "Statistics:" << nl;
|
||||
|
||||
Reference in New Issue
Block a user