Skip to content

Commit 4deb998

Browse files
Merge pull request #1212 from arcaneframework/dev/gg-revert-to-use-array-for-extra-ghost-builder
Revert to using 'UniqueArray' instead of 'std::set' to manage list of 'ExtraGhostBuilder'
2 parents d416ef3 + 1edf066 commit 4deb998

4 files changed

+27
-27
lines changed

arcane/src/arcane/mesh/ExtraGhostCellsBuilder.cc

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* ExtraGhostCellsBuilder.cc (C) 2000-2022 */
8+
/* ExtraGhostCellsBuilder.cc (C) 2000-2024 */
99
/* */
1010
/* Construction des mailles fantômes supplémentaires. */
1111
/*---------------------------------------------------------------------------*/
@@ -45,9 +45,9 @@ ExtraGhostCellsBuilder(DynamicMesh* mesh)
4545
void ExtraGhostCellsBuilder::
4646
addExtraGhostCellsBuilder(IExtraGhostCellsBuilder* builder)
4747
{
48-
if (m_builders.find(builder)!=m_builders.end())
48+
if (m_builders.contains(builder))
4949
ARCANE_FATAL("Instance {0} is already registered",builder);
50-
m_builders.insert(builder);
50+
m_builders.add(builder);
5151
}
5252

5353
/*---------------------------------------------------------------------------*/
@@ -56,10 +56,12 @@ addExtraGhostCellsBuilder(IExtraGhostCellsBuilder* builder)
5656
void ExtraGhostCellsBuilder::
5757
removeExtraGhostCellsBuilder(IExtraGhostCellsBuilder* builder)
5858
{
59-
auto x = m_builders.find(builder);
60-
if (x==m_builders.end())
59+
auto iter_begin = m_builders.begin();
60+
auto iter_end = m_builders.end();
61+
auto x = std::find(iter_begin,iter_end,builder);
62+
if (x==iter_end)
6163
ARCANE_FATAL("Instance {0} is not registered",builder);
62-
m_builders.erase(x);
64+
m_builders.remove(x - iter_begin);
6365
}
6466

6567
/*---------------------------------------------------------------------------*/

arcane/src/arcane/mesh/ExtraGhostCellsBuilder.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* ExtraGhostCellsBuilder.h (C) 2000-2022 */
8+
/* ExtraGhostCellsBuilder.h (C) 2000-2024 */
99
/* */
1010
/* Construction des mailles fantômes supplémentaires. */
1111
/*---------------------------------------------------------------------------*/
@@ -19,8 +19,6 @@
1919

2020
#include "arcane/mesh/MeshGlobal.h"
2121

22-
#include <set>
23-
2422
/*---------------------------------------------------------------------------*/
2523
/*---------------------------------------------------------------------------*/
2624

@@ -57,8 +55,8 @@ class ExtraGhostCellsBuilder
5755

5856
private:
5957

60-
DynamicMesh* m_mesh;
61-
std::set<IExtraGhostCellsBuilder*> m_builders;
58+
DynamicMesh* m_mesh = nullptr;
59+
UniqueArray<IExtraGhostCellsBuilder*> m_builders;
6260
};
6361

6462
/*---------------------------------------------------------------------------*/

arcane/src/arcane/mesh/ExtraGhostParticlesBuilder.cc

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* ExtraGhostParticlesBuilder.cc (C) 2000-2023 */
8+
/* ExtraGhostParticlesBuilder.cc (C) 2000-2024 */
99
/* */
1010
/* Construction des mailles fantômes supplémentaires. */
1111
/*---------------------------------------------------------------------------*/
@@ -47,9 +47,9 @@ ExtraGhostParticlesBuilder(DynamicMesh* mesh)
4747
void ExtraGhostParticlesBuilder::
4848
addExtraGhostParticlesBuilder(IExtraGhostParticlesBuilder* builder)
4949
{
50-
if (m_builders.find(builder)!=m_builders.end())
50+
if (m_builders.contains(builder))
5151
ARCANE_FATAL("Instance {0} is already registered",builder);
52-
m_builders.insert(builder);
52+
m_builders.add(builder);
5353
}
5454

5555
/*---------------------------------------------------------------------------*/
@@ -58,10 +58,12 @@ addExtraGhostParticlesBuilder(IExtraGhostParticlesBuilder* builder)
5858
void ExtraGhostParticlesBuilder::
5959
removeExtraGhostParticlesBuilder(IExtraGhostParticlesBuilder* builder)
6060
{
61-
auto x = m_builders.find(builder);
62-
if (x==m_builders.end())
61+
auto iter_begin = m_builders.begin();
62+
auto iter_end = m_builders.end();
63+
auto x = std::find(iter_begin,iter_end,builder);
64+
if (x==iter_end)
6365
ARCANE_FATAL("Instance {0} is not registered",builder);
64-
m_builders.erase(x);
66+
m_builders.remove(x - iter_begin);
6567
}
6668

6769
/*---------------------------------------------------------------------------*/

arcane/src/arcane/mesh/ExtraGhostParticlesBuilder.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* ExtraGhostParticlesBuilder.h (C) 2000-2022 */
8+
/* ExtraGhostParticlesBuilder.h (C) 2000-2024 */
99
/* */
1010
/* Construction des mailles fantômes supplémentaires. */
1111
/*---------------------------------------------------------------------------*/
@@ -19,8 +19,6 @@
1919

2020
#include "arcane/mesh/MeshGlobal.h"
2121

22-
#include <set>
23-
2422
/*---------------------------------------------------------------------------*/
2523
/*---------------------------------------------------------------------------*/
2624

@@ -51,7 +49,7 @@ class ExtraGhostParticlesBuilder
5149
{
5250
public:
5351

54-
ExtraGhostParticlesBuilder(DynamicMesh* mesh);
52+
explicit ExtraGhostParticlesBuilder(DynamicMesh* mesh);
5553

5654
public:
5755

@@ -62,8 +60,8 @@ class ExtraGhostParticlesBuilder
6260

6361
private:
6462

65-
DynamicMesh* m_mesh;
66-
std::set<IExtraGhostParticlesBuilder*> m_builders;
63+
DynamicMesh* m_mesh = nullptr;
64+
UniqueArray<IExtraGhostParticlesBuilder*> m_builders;
6765

6866
private:
6967

0 commit comments

Comments
 (0)