Skip to content

Commit af71274

Browse files
authored
Merge pull request #14551 from corngood/static-data-headers
Remove static data from headers
2 parents 3645671 + 1b5af49 commit af71274

File tree

10 files changed

+37
-26
lines changed

10 files changed

+37
-26
lines changed

src/libcmd/command.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <nlohmann/json.hpp>
33

44
#include "nix/cmd/command.hh"
5+
#include "nix/cmd/legacy.hh"
56
#include "nix/cmd/markdown.hh"
67
#include "nix/store/store-open.hh"
78
#include "nix/store/local-fs-store.hh"
@@ -14,6 +15,18 @@
1415

1516
namespace nix {
1617

18+
RegisterCommand::Commands & RegisterCommand::commands()
19+
{
20+
static RegisterCommand::Commands commands;
21+
return commands;
22+
}
23+
24+
RegisterLegacyCommand::Commands & RegisterLegacyCommand::commands()
25+
{
26+
static RegisterLegacyCommand::Commands commands;
27+
return commands;
28+
}
29+
1730
nix::Commands RegisterCommand::getCommandsFor(const std::vector<std::string> & prefix)
1831
{
1932
nix::Commands res;

src/libcmd/include/nix/cmd/command.hh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,7 @@ struct RegisterCommand
286286
{
287287
typedef std::map<std::vector<std::string>, std::function<ref<Command>()>> Commands;
288288

289-
static Commands & commands()
290-
{
291-
static Commands commands;
292-
return commands;
293-
}
289+
static Commands & commands();
294290

295291
RegisterCommand(std::vector<std::string> && name, std::function<ref<Command>()> command)
296292
{

src/libcmd/include/nix/cmd/legacy.hh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ struct RegisterLegacyCommand
1313
{
1414
typedef std::map<std::string, MainFunction> Commands;
1515

16-
static Commands & commands()
17-
{
18-
static Commands commands;
19-
return commands;
20-
}
16+
static Commands & commands();
2117

2218
RegisterLegacyCommand(const std::string & name, MainFunction fun)
2319
{

src/libexpr/include/nix/expr/primops.hh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ struct RegisterPrimOp
1212
{
1313
typedef std::vector<PrimOp> PrimOps;
1414

15-
static PrimOps & primOps()
16-
{
17-
static PrimOps primOps;
18-
return primOps;
19-
}
15+
static PrimOps & primOps();
2016

2117
/**
2218
* You can register a constant by passing an arity of 0. fun

src/libexpr/include/nix/expr/print-options.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct PrintOptions
110110
* `PrintOptions` for unknown and therefore potentially large values in error messages,
111111
* to avoid printing "too much" output.
112112
*/
113-
static PrintOptions errorPrintOptions = PrintOptions{
113+
static constexpr PrintOptions errorPrintOptions = PrintOptions{
114114
.ansiColors = true,
115115
.maxDepth = 10,
116116
.maxAttrs = 10,

src/libexpr/primops.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040

4141
namespace nix {
4242

43+
RegisterPrimOp::PrimOps & RegisterPrimOp::primOps()
44+
{
45+
static RegisterPrimOp::PrimOps primOps;
46+
return primOps;
47+
}
48+
4349
/*************************************************************
4450
* Miscellaneous
4551
*************************************************************/

src/libstore/builtins/buildenv.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
namespace nix {
1212

13+
RegisterBuiltinBuilder::BuiltinBuilders & RegisterBuiltinBuilder::builtinBuilders()
14+
{
15+
static RegisterBuiltinBuilder::BuiltinBuilders builders;
16+
return builders;
17+
}
18+
1319
namespace {
1420

1521
struct State

src/libstore/include/nix/store/builtins.hh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ struct RegisterBuiltinBuilder
3333
{
3434
typedef std::map<std::string, BuiltinBuilder> BuiltinBuilders;
3535

36-
static BuiltinBuilders & builtinBuilders()
37-
{
38-
static BuiltinBuilders builders;
39-
return builders;
40-
}
36+
static BuiltinBuilders & builtinBuilders();
4137

4238
RegisterBuiltinBuilder(const std::string & name, BuiltinBuilder && fun)
4339
{

src/libutil/config-global.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
namespace nix {
66

7+
GlobalConfig::ConfigRegistrations & GlobalConfig::configRegistrations()
8+
{
9+
static GlobalConfig::ConfigRegistrations configRegistrations;
10+
return configRegistrations;
11+
}
12+
713
bool GlobalConfig::set(const std::string & name, const std::string & value)
814
{
915
for (auto & config : configRegistrations())

src/libutil/include/nix/util/config-global.hh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ struct GlobalConfig : public AbstractConfig
99
{
1010
typedef std::vector<Config *> ConfigRegistrations;
1111

12-
static ConfigRegistrations & configRegistrations()
13-
{
14-
static ConfigRegistrations configRegistrations;
15-
return configRegistrations;
16-
}
12+
static ConfigRegistrations & configRegistrations();
1713

1814
bool set(const std::string & name, const std::string & value) override;
1915

0 commit comments

Comments
 (0)