Skip to content

Commit 7f7262a

Browse files
committed
Pass std::string by value and use std::move() to move it
1 parent 1d19e4f commit 7f7262a

File tree

16 files changed

+43
-36
lines changed

16 files changed

+43
-36
lines changed

src/sst/core/componentInfo.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020

2121
#include <cinttypes>
2222
#include <cstdio>
23+
#include <utility>
2324

2425
namespace SST {
2526

26-
ComponentInfo::ComponentInfo(ComponentId_t id, const std::string& name) :
27+
ComponentInfo::ComponentInfo(ComponentId_t id, std::string name) :
2728
id_(id),
2829
parent_info(nullptr),
29-
name(name),
30+
name(std::move(name)),
3031
type(""),
3132
link_map(nullptr),
3233
component(nullptr),
@@ -81,12 +82,12 @@ ComponentInfo::ComponentInfo() :
8182
// }
8283

8384
// Constructor used for Anonymous SubComponents
84-
ComponentInfo::ComponentInfo(ComponentId_t id, ComponentInfo* parent_info, const std::string& type,
85-
const std::string& slot_name, int slot_num, uint64_t share_flags /*, const Params& params_in*/) :
85+
ComponentInfo::ComponentInfo(ComponentId_t id, ComponentInfo* parent_info, std::string type, std::string slot_name,
86+
int slot_num, uint64_t share_flags /*, const Params& params_in*/) :
8687
id_(id),
8788
parent_info(parent_info),
8889
name(""),
89-
type(type),
90+
type(std::move(type)),
9091
link_map(nullptr),
9192
component(nullptr),
9293
params(/*new Params()*/ nullptr),
@@ -97,7 +98,7 @@ ComponentInfo::ComponentInfo(ComponentId_t id, ComponentInfo* parent_info, const
9798
statLoadLevel(0),
9899
coordinates(parent_info->coordinates),
99100
subIDIndex(1),
100-
slot_name(slot_name),
101+
slot_name(std::move(slot_name)),
101102
slot_num(slot_num),
102103
share_flags(share_flags)
103104
{
@@ -387,11 +388,10 @@ ComponentInfo::hasLinks() const
387388

388389
//// Functions for testing serialization
389390

390-
ComponentInfo::ComponentInfo(
391-
ComponentId_t id, const std::string& name, const std::string& slot_name, TimeConverter tv) :
391+
ComponentInfo::ComponentInfo(ComponentId_t id, std::string name, std::string slot_name, TimeConverter tv) :
392392
id_(id),
393393
parent_info(nullptr),
394-
name(name),
394+
name(std::move(name)),
395395
type(""),
396396
link_map(nullptr),
397397
component(nullptr),
@@ -403,7 +403,7 @@ ComponentInfo::ComponentInfo(
403403
all_stat_config_(nullptr),
404404
coordinates(3, 0.0),
405405
subIDIndex(1),
406-
slot_name(slot_name),
406+
slot_name(std::move(slot_name)),
407407
slot_num(-1),
408408
share_flags(0)
409409
{}

src/sst/core/componentInfo.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class ComponentInfo
158158
// inline void setParent(BaseComponent* comp) { parent = comp; }
159159

160160
/* Lookup Key style constructor */
161-
ComponentInfo(ComponentId_t id, const std::string& name);
161+
ComponentInfo(ComponentId_t id, std::string name);
162162
void finalizeLinkConfiguration() const;
163163
void prepareForComplete() const;
164164

@@ -181,8 +181,8 @@ class ComponentInfo
181181
ComponentInfo(const std::string& type, const Params* params, const ComponentInfo* parent_info);
182182

183183
/* Anonymous SubComponent */
184-
ComponentInfo(ComponentId_t id, ComponentInfo* parent_info, const std::string& type, const std::string& slot_name,
185-
int slot_num, uint64_t share_flags /*, const Params& params_in*/);
184+
ComponentInfo(ComponentId_t id, ComponentInfo* parent_info, std::string type, std::string slot_name, int slot_num,
185+
uint64_t share_flags /*, const Params& params_in*/);
186186

187187
/* New ELI Style */
188188
ComponentInfo(ConfigComponent* ccomp, const std::string& name, ComponentInfo* parent_info, LinkMap* link_map);
@@ -272,8 +272,7 @@ class ComponentInfo
272272
/**
273273
(DO NOT USE) Constructor used only for serialization testing
274274
*/
275-
ComponentInfo(
276-
ComponentId_t id, const std::string& name, const std::string& slot_name, TimeConverter tv = TimeConverter());
275+
ComponentInfo(ComponentId_t id, std::string name, std::string slot_name, TimeConverter tv = TimeConverter());
277276

278277
ComponentInfo* test_addSubComponentInfo(
279278
const std::string& name, const std::string& slot_name, TimeConverter tv = TimeConverter());

src/sst/core/elemLoader.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <cstring>
2525
#include <dirent.h>
2626
#include <ostream>
27+
#include <utility>
2728
#include <vector>
2829

2930
#ifdef HAVE_DLFCN_H
@@ -120,8 +121,8 @@ splitPath(const std::string& searchPaths)
120121
return paths;
121122
}
122123

123-
ElemLoader::ElemLoader(const std::string& searchPaths) :
124-
searchPaths(searchPaths),
124+
ElemLoader::ElemLoader(std::string searchPaths) :
125+
searchPaths(std::move(searchPaths)),
125126
verbose(false),
126127
bindPolicy(RTLD_LAZY | RTLD_GLOBAL)
127128
{

src/sst/core/elemLoader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ElemLoader
2424
{
2525
public:
2626
/** Create a new ElementLoader with a given searchpath of directories */
27-
explicit ElemLoader(const std::string& searchPaths);
27+
explicit ElemLoader(std::string searchPaths);
2828
~ElemLoader() = default;
2929

3030
/**

src/sst/core/impl/partitioners/rrobin.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
#include "sst/core/model/configGraph.h"
1717
#include "sst/core/warnmacros.h"
1818

19+
#include <utility>
20+
1921
namespace SST::IMPL::Partition {
2022

2123
SSTRoundRobinPartition::SSTRoundRobinPartition(RankInfo world_size, RankInfo UNUSED(my_rank), int UNUSED(verbosity)) :
2224
SSTPartitioner(),
23-
world_size(world_size)
25+
world_size(std::move(world_size))
2426
{}
2527

2628
void

src/sst/core/impl/partitioners/simplepart.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace SST::IMPL::Partition {
2525

2626
SimplePartitioner::SimplePartitioner(RankInfo total_ranks, RankInfo UNUSED(my_rank), int UNUSED(verbosity)) :
2727
SSTPartitioner(),
28-
world_size(total_ranks),
28+
world_size(std::move(total_ranks)),
2929
total_parts(world_size.rank * world_size.thread)
3030
{}
3131

src/sst/core/model/restart/sstcptmodel.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
#include <cstdint>
2121
#include <fstream>
2222
#include <string>
23+
#include <utility>
2324

2425
// #include "nlohmann/json.hpp"
2526
// using json = nlohmann::json;
2627

2728
namespace SST::Core {
2829

2930
SSTCPTModelDefinition::SSTCPTModelDefinition(
30-
const std::string& script_file, int UNUSED(verbosity), Config* config, double UNUSED(start_time)) :
31+
std::string script_file, int UNUSED(verbosity), Config* config, double UNUSED(start_time)) :
3132
SSTModelDescription(config),
32-
manifest_(script_file),
33+
manifest_(std::move(script_file)),
3334
config_(config)
3435
{}
3536

src/sst/core/model/restart/sstcptmodel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class SSTCPTModelDefinition : public SSTModelDescription
4343

4444
SST_ELI_DOCUMENT_MODEL_SUPPORTED_EXTENSIONS(".sstcpt")
4545

46-
SSTCPTModelDefinition(const std::string& script_file, int verbosity, Config* config, double start_time);
46+
SSTCPTModelDefinition(std::string script_file, int verbosity, Config* config, double start_time);
4747
~SSTCPTModelDefinition() = default;
4848

4949
ConfigGraph* createConfigGraph() override;

src/sst/core/profile/profiletool.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
#include "sst/core/sst_types.h"
1717

1818
#include <atomic>
19+
#include <utility>
1920

2021
namespace SST::Profile {
2122

2223
SST_ELI_DEFINE_INFO_EXTERN(ProfileTool)
2324
SST_ELI_DEFINE_CTOR_EXTERN(ProfileTool)
2425

25-
ProfileTool::ProfileTool(const std::string& name) :
26-
name(name)
26+
ProfileTool::ProfileTool(std::string name) :
27+
name(std::move(name))
2728
{}
2829

2930
} // namespace SST::Profile

src/sst/core/profile/profiletool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ProfileTool
3939
ELI::ProvidesInterface,
4040
ELI::ProvidesParams)
4141

42-
explicit ProfileTool(const std::string& name);
42+
explicit ProfileTool(std::string name);
4343

4444
virtual ~ProfileTool() {}
4545

0 commit comments

Comments
 (0)