summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorHerman Semenoff <GermanAizek@yandex.ru>2026-04-08 11:51:08 +0300
committerJulian Andres Klode <jak@debian.org>2026-04-08 10:40:55 +0000
commitef70431f02e2ec13ecedab7ac342574e52d1877b (patch)
treede51c6f3ce74d0b7fd1ddacd0812cd1cbe116c14 /apt-pkg
parent5b649fb72ecdced056fb3daab02e88933cc7a32a (diff)
apt: push to emplace C++11 if possible
References: - https://www.reddit.com/r/cpp_questions/comments/pm63yx/why_clangtidy_says_use_emplace_back_instead_of/ - https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-emplace.html
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/fileutl.cc2
-rw-r--r--apt-pkg/contrib/strutl.cc2
-rw-r--r--apt-pkg/deb/dpkgpm.cc16
-rw-r--r--apt-pkg/solver3.cc14
4 files changed, 17 insertions, 17 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 69e6dc430..74f5ec8bc 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -3091,7 +3091,7 @@ std::vector<std::string> Glob(std::string const &pattern, int flags)
// append results
for(i=0;i<globbuf.gl_pathc;i++)
- result.push_back(string(globbuf.gl_pathv[i]));
+ result.emplace_back(globbuf.gl_pathv[i]);
globfree(&globbuf);
return result;
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 4363ab818..bfd4967f5 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1335,7 +1335,7 @@ vector<string> VectorizeString(string_view const &haystack, char const &split)
auto end = start;
do {
for (; end != haystack.end() && *end != split; ++end);
- exploded.push_back(string(start, end));
+ exploded.emplace_back(start, end);
start = end + 1;
} while (end != haystack.end() && (++end) != haystack.end());
return exploded;
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 395227f50..0f1d407b7 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -266,12 +266,12 @@ bool pkgDPkgPM::Configure(PkgIterator Pkg)
if (Pkg.end() == true)
return false;
- List.push_back(Item(Item::Configure, Pkg));
+ List.emplace_back(Item::Configure, Pkg);
// Use triggers for config calls if we configure "smart"
// as otherwise Pre-Depends will not be satisfied, see #526774
if (_config->FindB("DPkg::TriggersPending", false) == true)
- List.push_back(Item(Item::TriggersPending, PkgIterator()));
+ List.emplace_back(Item::TriggersPending, PkgIterator());
return true;
}
@@ -285,9 +285,9 @@ bool pkgDPkgPM::Remove(PkgIterator Pkg,bool Purge)
return false;
if (Purge == true)
- List.push_back(Item(Item::Purge,Pkg));
+ List.emplace_back(Item::Purge,Pkg);
else
- List.push_back(Item(Item::Remove,Pkg));
+ List.emplace_back(Item::Remove,Pkg);
return true;
}
/*}}}*/
@@ -2328,10 +2328,10 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
// do not report dpkg I/O errors, this is a format string, so we compare
// the prefix and the suffix of the error with the dpkg error message
vector<string> io_errors;
- io_errors.push_back(string("failed to read"));
- io_errors.push_back(string("failed to write"));
- io_errors.push_back(string("failed to seek"));
- io_errors.push_back(string("unexpected end of file or stream"));
+ io_errors.emplace_back("failed to read");
+ io_errors.emplace_back("failed to write");
+ io_errors.emplace_back("failed to seek");
+ io_errors.emplace_back("unexpected end of file or stream");
for (vector<string>::iterator I = io_errors.begin(); I != io_errors.end(); ++I)
{
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc
index bfc187ea6..06132995b 100644
--- a/apt-pkg/solver3.cc
+++ b/apt-pkg/solver3.cc
@@ -949,7 +949,7 @@ void DependencySolver::Discover(Var var)
{
Clause clause{Var(Pkg), Group::SelectVersion};
for (auto ver = Pkg.VersionList(); not ver.end(); ver++)
- clause.solutions.push_back(Var(ver));
+ clause.solutions.emplace_back(ver);
std::stable_sort(clause.solutions.begin(), clause.solutions.end(), CompareProviders3{cache, policy, Pkg, *this});
RegisterClause(std::move(clause));
@@ -1067,7 +1067,7 @@ Clause DependencySolver::TranslateOrGroup(pkgCache::DepIterator start, pkgCache:
if (DeferVersionSelection && not start.IsNegative() && start.TargetPkg().ProvidesList().end() && start.IsSatisfied(start.TargetPkg()))
{
- clause.solutions.push_back(Var(start.TargetPkg()));
+ clause.solutions.emplace_back(start.TargetPkg());
}
else
{
@@ -1079,7 +1079,7 @@ Clause DependencySolver::TranslateOrGroup(pkgCache::DepIterator start, pkgCache:
if (unlikely(debug >= 3))
std::cerr << "Adding work to item " << reason.toString(cache) << " -> " << tgti.ParentPkg().FullName() << "=" << tgti.VerStr() << (clause.negative ? " (negative)" : "") << "\n";
- clause.solutions.push_back(Var(pkgCache::VerIterator(cache, *tgt)));
+ clause.solutions.emplace_back(pkgCache::VerIterator(cache, *tgt));
}
std::stable_sort(clause.solutions.begin() + begin, clause.solutions.end(), CompareProviders3{cache, policy, start.TargetPkg(), *this});
}
@@ -1259,13 +1259,13 @@ bool DependencySolver::FromDepCache(pkgDepCache &depcache)
else
{
Clause w{Var(), Group, isOptional};
- w.solutions.push_back(Var(P));
+ w.solutions.emplace_back(P);
auto insertedW = RegisterClause(std::move(w));
if (insertedW && not AddWork(Work{insertedW, decisionLevel()}))
return false;
if (not isAuto)
- manualPackages.push_back(Var(P));
+ manualPackages.emplace_back(P);
// Given A->A2|A1, B->B1|B2; Bn->An, if we select `not A1`, we
// should try to install A2 before trying B so we end up with
@@ -1274,7 +1274,7 @@ bool DependencySolver::FromDepCache(pkgDepCache &depcache)
// Compare test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch
Clause shortcircuit{Var(), Group, isOptional};
for (auto V = P.VersionList(); not V.end(); ++V)
- shortcircuit.solutions.push_back(Var(V));
+ shortcircuit.solutions.emplace_back(V);
std::stable_sort(shortcircuit.solutions.begin(), shortcircuit.solutions.end(), CompareProviders3{cache, policy, P, *this});
auto insertedShort = RegisterClause(std::move(shortcircuit));
if (insertedShort && not AddWork(Work{insertedShort, decisionLevel()}))
@@ -1291,7 +1291,7 @@ bool DependencySolver::FromDepCache(pkgDepCache &depcache)
auto G = P.Group();
for (auto P = G.PackageList(); not P.end(); P = G.NextPkg(P))
if (P->Flags & pkgCache::Flag::Essential)
- w.solutions.push_back(Var(P));
+ w.solutions.emplace_back(P);
std::stable_sort(w.solutions.begin(), w.solutions.end(), CompareProviders3{cache, policy, P, *this});
if (unlikely(debug >= 1))
std::cerr << "Install essential package " << P << std::endl;