Skip to content

Commit df552ff

Browse files
committed
Remove std::string alias (for real this time)
Also use std::string_view in a few more places.
1 parent 14b38d0 commit df552ff

File tree

110 files changed

+774
-682
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+774
-682
lines changed

perl/lib/Nix/Store.xs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ SV * convertHash(char * algo, char * s, int toBase32)
240240
PPCODE:
241241
try {
242242
auto h = Hash::parseAny(s, parseHashType(algo));
243-
string s = h.to_string(toBase32 ? Base32 : Base16, false);
243+
auto s = h.to_string(toBase32 ? Base32 : Base16, false);
244244
XPUSHs(sv_2mortal(newSVpv(s.c_str(), 0)));
245245
} catch (Error & e) {
246246
croak("%s", e.what());

src/build-remote/build-remote.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ std::string escapeUri(std::string uri)
3232
return uri;
3333
}
3434

35-
static string currentLoad;
35+
static std::string currentLoad;
3636

3737
static AutoCloseFD openSlotLock(const Machine & m, uint64_t slot)
3838
{
@@ -97,7 +97,7 @@ static int main_build_remote(int argc, char * * argv)
9797
}
9898

9999
std::optional<StorePath> drvPath;
100-
string storeUri;
100+
std::string storeUri;
101101

102102
while (true) {
103103

@@ -183,7 +183,7 @@ static int main_build_remote(int argc, char * * argv)
183183
else
184184
{
185185
// build the hint template.
186-
string errorText =
186+
std::string errorText =
187187
"Failed to find a machine for remote build!\n"
188188
"derivation: %s\nrequired (system, features): (%s, %s)";
189189
errorText += "\n%s available machines:";
@@ -193,7 +193,7 @@ static int main_build_remote(int argc, char * * argv)
193193
errorText += "\n(%s, %s, %s, %s)";
194194

195195
// add the template values.
196-
string drvstr;
196+
std::string drvstr;
197197
if (drvPath.has_value())
198198
drvstr = drvPath->to_string();
199199
else
@@ -208,7 +208,7 @@ static int main_build_remote(int argc, char * * argv)
208208

209209
for (auto & m : machines)
210210
error
211-
% concatStringsSep<std::vector<string>>(", ", m.systemTypes)
211+
% concatStringsSep<std::vector<std::string>>(", ", m.systemTypes)
212212
% m.maxJobs
213213
% concatStringsSep<StringSet>(", ", m.supportedFeatures)
214214
% concatStringsSep<StringSet>(", ", m.mandatoryFeatures);

src/libexpr/attr-path.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace nix {
99
static Strings parseAttrPath(std::string_view s)
1010
{
1111
Strings res;
12-
string cur;
12+
std::string cur;
1313
auto i = s.begin();
1414
while (i != s.end()) {
1515
if (*i == '.') {
@@ -41,7 +41,7 @@ std::vector<Symbol> parseAttrPath(EvalState & state, std::string_view s)
4141
}
4242

4343

44-
std::pair<Value *, Pos> findAlongAttrPath(EvalState & state, const string & attrPath,
44+
std::pair<Value *, Pos> findAlongAttrPath(EvalState & state, const std::string & attrPath,
4545
Bindings & autoArgs, Value & vIn)
4646
{
4747
Strings tokens = parseAttrPath(attrPath);
@@ -121,7 +121,7 @@ Pos findPackageFilename(EvalState & state, Value & v, std::string what)
121121
std::string filename(pos, 0, colon);
122122
unsigned int lineno;
123123
try {
124-
lineno = std::stoi(std::string(pos, colon + 1, string::npos));
124+
lineno = std::stoi(std::string(pos, colon + 1, std::string::npos));
125125
} catch (std::invalid_argument & e) {
126126
throw ParseError("cannot parse line number '%s'", pos);
127127
}

src/libexpr/attr-path.hh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ namespace nix {
1010
MakeError(AttrPathNotFound, Error);
1111
MakeError(NoPositionInfo, Error);
1212

13-
std::pair<Value *, Pos> findAlongAttrPath(EvalState & state, const string & attrPath,
14-
Bindings & autoArgs, Value & vIn);
13+
std::pair<Value *, Pos> findAlongAttrPath(
14+
EvalState & state,
15+
const std::string & attrPath,
16+
Bindings & autoArgs,
17+
Value & vIn);
1518

1619
/* Heuristic to find the filename and lineno or a nix value. */
1720
Pos findPackageFilename(EvalState & state, Value & v, std::string what);

src/libexpr/attr-set.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public:
105105
for (size_t n = 0; n < size_; n++)
106106
res.emplace_back(&attrs[n]);
107107
std::sort(res.begin(), res.end(), [](const Attr * a, const Attr * b) {
108-
return (const string &) a->name < (const string &) b->name;
108+
return (const std::string &) a->name < (const std::string &) b->name;
109109
});
110110
return res;
111111
}

src/libexpr/common-eval-args.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,25 @@ Bindings * MixEvalArgs::getAutoArgs(EvalState & state)
7777
for (auto & i : autoArgs) {
7878
auto v = state.allocValue();
7979
if (i.second[0] == 'E')
80-
state.mkThunk_(*v, state.parseExprFromString(string(i.second, 1), absPath(".")));
80+
state.mkThunk_(*v, state.parseExprFromString(i.second.substr(1), absPath(".")));
8181
else
8282
v->mkString(((std::string_view) i.second).substr(1));
8383
res.insert(state.symbols.create(i.first), v);
8484
}
8585
return res.finish();
8686
}
8787

88-
Path lookupFileArg(EvalState & state, string s)
88+
Path lookupFileArg(EvalState & state, std::string_view s)
8989
{
9090
if (isUri(s)) {
9191
return state.store->toRealPath(
9292
fetchers::downloadTarball(
9393
state.store, resolveUri(s), "source", false).first.storePath);
9494
} else if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') {
95-
Path p = s.substr(1, s.size() - 2);
95+
Path p(s.substr(1, s.size() - 2));
9696
return state.findFile(p);
9797
} else
98-
return absPath(s);
98+
return absPath(std::string(s));
9999
}
100100

101101
}

src/libexpr/common-eval-args.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ private:
2222
std::map<std::string, std::string> autoArgs;
2323
};
2424

25-
Path lookupFileArg(EvalState & state, string s);
25+
Path lookupFileArg(EvalState & state, std::string_view s);
2626

2727
}

src/libexpr/eval-cache.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ std::vector<Symbol> AttrCursor::getAttrs()
596596
for (auto & attr : *getValue().attrs)
597597
attrs.push_back(attr.name);
598598
std::sort(attrs.begin(), attrs.end(), [](const Symbol & a, const Symbol & b) {
599-
return (const string &) a < (const string &) b;
599+
return (const std::string &) a < (const std::string &) b;
600600
});
601601

602602
if (root->db)

0 commit comments

Comments
 (0)