From 8433ddee0e3753b0b52f7b49a8bfbc6b3e26d799 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 24 Jan 2019 17:00:12 +0100 Subject: [PATCH] ENH: simplify coding in functionObjectList - use for-range when iterating - dictionary access/search methods - autoPtr for memory management --- .../functionObjectList/functionObjectList.C | 195 +++++++++--------- .../functionObjectList/functionObjectList.H | 23 ++- 2 files changed, 108 insertions(+), 110 deletions(-) diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 8da391cc8d..30bfd63210 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,31 +67,30 @@ void Foam::functionObjectList::createStateDict() const } -Foam::functionObject* Foam::functionObjectList::remove +Foam::autoPtr Foam::functionObjectList::remove ( const word& key, label& oldIndex ) { - functionObject* ptr = nullptr; + autoPtr oldptr; - // Find index of existing functionObject - HashTable