Skip to content

Commit

Permalink
Remove std::vector alias
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Feb 21, 2022
1 parent fe9afb6 commit 1ac2664
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/build-remote/build-remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static int main_build_remote(int argc, char * * argv)

for (auto & m : machines)
error
% concatStringsSep<vector<string>>(", ", m.systemTypes)
% concatStringsSep<std::vector<string>>(", ", m.systemTypes)
% m.maxJobs
% concatStringsSep<StringSet>(", ", m.supportedFeatures)
% concatStringsSep<StringSet>(", ", m.mandatoryFeatures);
Expand Down
4 changes: 2 additions & 2 deletions src/libexpr/nixexpr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ struct ExprConcatStrings : Expr
{
Pos pos;
bool forceString;
vector<std::pair<Pos, Expr *> > * es;
ExprConcatStrings(const Pos & pos, bool forceString, vector<std::pair<Pos, Expr *> > * es)
std::vector<std::pair<Pos, Expr *> > * es;
ExprConcatStrings(const Pos & pos, bool forceString, std::vector<std::pair<Pos, Expr *> > * es)
: pos(pos), forceString(forceString), es(es) { };
COMMON_METHODS
};
Expand Down
16 changes: 8 additions & 8 deletions src/libexpr/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static Formals * toFormals(ParseData & data, ParserFormals * formals,


static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols,
vector<std::pair<Pos, std::variant<Expr *, StringToken> > > & es)
std::vector<std::pair<Pos, std::variant<Expr *, StringToken> > > & es)
{
if (es.empty()) return new ExprString("");

Expand Down Expand Up @@ -233,7 +233,7 @@ static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols,
}

/* Strip spaces from each line. */
vector<std::pair<Pos, Expr *> > * es2 = new vector<std::pair<Pos, Expr *> >;
std::vector<std::pair<Pos, Expr *> > * es2 = new std::vector<std::pair<Pos, Expr *> >;
atStartOfLine = true;
size_t curDropped = 0;
size_t n = es.size();
Expand Down Expand Up @@ -415,7 +415,7 @@ expr_op
| expr_op UPDATE expr_op { $$ = new ExprOpUpdate(CUR_POS, $1, $3); }
| expr_op '?' attrpath { $$ = new ExprOpHasAttr($1, *$3); }
| expr_op '+' expr_op
{ $$ = new ExprConcatStrings(CUR_POS, false, new vector<std::pair<Pos, Expr *> >({{makeCurPos(@1, data), $1}, {makeCurPos(@3, data), $3}})); }
{ $$ = new ExprConcatStrings(CUR_POS, false, new std::vector<std::pair<Pos, Expr *> >({{makeCurPos(@1, data), $1}, {makeCurPos(@3, data), $3}})); }
| expr_op '-' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__sub")), {$1, $3}); }
| expr_op '*' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__mul")), {$1, $3}); }
| expr_op '/' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__div")), {$1, $3}); }
Expand Down Expand Up @@ -503,9 +503,9 @@ string_parts_interpolated
: string_parts_interpolated STR
{ $$ = $1; $1->emplace_back(makeCurPos(@2, data), new ExprString(string($2))); }
| string_parts_interpolated DOLLAR_CURLY expr '}' { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $3); }
| DOLLAR_CURLY expr '}' { $$ = new vector<std::pair<Pos, Expr *> >; $$->emplace_back(makeCurPos(@1, data), $2); }
| DOLLAR_CURLY expr '}' { $$ = new std::vector<std::pair<Pos, Expr *> >; $$->emplace_back(makeCurPos(@1, data), $2); }
| STR DOLLAR_CURLY expr '}' {
$$ = new vector<std::pair<Pos, Expr *> >;
$$ = new std::vector<std::pair<Pos, Expr *> >;
$$->emplace_back(makeCurPos(@1, data), new ExprString(string($1)));
$$->emplace_back(makeCurPos(@2, data), $3);
}
Expand All @@ -528,7 +528,7 @@ path_start
ind_string_parts
: ind_string_parts IND_STR { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $2); }
| ind_string_parts DOLLAR_CURLY expr '}' { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $3); }
| { $$ = new vector<std::pair<Pos, std::variant<Expr *, StringToken> > >; }
| { $$ = new std::vector<std::pair<Pos, std::variant<Expr *, StringToken> > >; }
;

binds
Expand Down Expand Up @@ -582,9 +582,9 @@ attrpath
} else
$$->push_back(AttrName($3));
}
| attr { $$ = new vector<AttrName>; $$->push_back(AttrName(data->symbols.create($1))); }
| attr { $$ = new std::vector<AttrName>; $$->push_back(AttrName(data->symbols.create($1))); }
| string_attr
{ $$ = new vector<AttrName>;
{ $$ = new std::vector<AttrName>;
ExprString *str = dynamic_cast<ExprString *>($1);
if (str) {
$$->push_back(AttrName(data->symbols.create(str->s)));
Expand Down
4 changes: 2 additions & 2 deletions src/libexpr/primops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3649,12 +3649,12 @@ static void prim_replaceStrings(EvalState & state, const Pos & pos, Value * * ar
.errPos = pos
});

vector<string> from;
std::vector<string> from;
from.reserve(args[0]->listSize());
for (auto elem : args[0]->listItems())
from.emplace_back(state.forceString(*elem, pos));

vector<std::pair<string, PathSet>> to;
std::vector<std::pair<string, PathSet>> to;
to.reserve(args[1]->listSize());
for (auto elem : args[1]->listItems()) {
PathSet ctx;
Expand Down
4 changes: 2 additions & 2 deletions src/libutil/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void AbstractConfig::applyConfig(const std::string & contents, const std::string
if (hash != string::npos)
line = string(line, 0, hash);

vector<string> tokens = tokenizeString<vector<string> >(line);
auto tokens = tokenizeString<std::vector<string>>(line);
if (tokens.empty()) continue;

if (tokens.size() < 2)
Expand Down Expand Up @@ -122,7 +122,7 @@ void AbstractConfig::applyConfig(const std::string & contents, const std::string

string name = tokens[0];

vector<string>::iterator i = tokens.begin();
auto i = tokens.begin();
advance(i, 2);

set(name, concatStringsSep(" ", Strings(i, tokens.end()))); // FIXME: slow
Expand Down
3 changes: 1 addition & 2 deletions src/libutil/types.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace nix {

using std::vector;
using std::string;

typedef std::list<string> Strings;
Expand All @@ -25,7 +24,7 @@ typedef std::string_view PathView;
typedef std::list<Path> Paths;
typedef std::set<Path> PathSet;

typedef vector<std::pair<string, string>> Headers;
typedef std::vector<std::pair<string, string>> Headers;

/* Helper class to run code at startup. */
template<typename T>
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ template<class C> C tokenizeString(std::string_view s, std::string_view separato

template Strings tokenizeString(std::string_view s, std::string_view separators);
template StringSet tokenizeString(std::string_view s, std::string_view separators);
template vector<string> tokenizeString(std::string_view s, std::string_view separators);
template std::vector<string> tokenizeString(std::string_view s, std::string_view separators);


string chomp(std::string_view s)
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/util.hh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct DirEntry
: name(name), ino(ino), type(type) { }
};

typedef vector<DirEntry> DirEntries;
typedef std::vector<DirEntry> DirEntries;

DirEntries readDirectory(const Path & path);

Expand Down
6 changes: 3 additions & 3 deletions src/nix-env/nix-env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ void printTable(Table & table)
{
auto nrColumns = table.size() > 0 ? table.front().size() : 0;

vector<size_t> widths;
std::vector<size_t> widths;
widths.resize(nrColumns);

for (auto & i : table) {
Expand Down Expand Up @@ -907,7 +907,7 @@ static VersionDiff compareVersionAgainstSet(
}


static void queryJSON(Globals & globals, vector<DrvInfo> & elems, bool printOutPath, bool printMeta)
static void queryJSON(Globals & globals, std::vector<DrvInfo> & elems, bool printOutPath, bool printMeta)
{
JSONObject topObj(cout, true);
for (auto & i : elems) {
Expand Down Expand Up @@ -1020,7 +1020,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)

/* Sort them by name. */
/* !!! */
vector<DrvInfo> elems;
std::vector<DrvInfo> elems;
for (auto & i : elems_) elems.push_back(i);
sort(elems.begin(), elems.end(), cmpElemByName);

Expand Down

0 comments on commit 1ac2664

Please sign in to comment.