about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/derivations.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-20T21·27+0100
committerVincent Ambo <tazjin@google.com>2020-05-20T21·27+0100
commit689ef502f5b0655c9923ed77da2ae3504630f473 (patch)
tree3e331c153646f136875f047cc3b9f0aad8c86341 /third_party/nix/src/libstore/derivations.cc
parentd331d3a0b5c497a46e2636f308234be66566c04c (diff)
refactor(3p/nix): Apply clang-tidy's readability-* fixes r/788
This applies the readability fixes listed here:

https://clang.llvm.org/extra/clang-tidy/checks/list.html
Diffstat (limited to 'third_party/nix/src/libstore/derivations.cc')
-rw-r--r--third_party/nix/src/libstore/derivations.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/third_party/nix/src/libstore/derivations.cc b/third_party/nix/src/libstore/derivations.cc
index 2955056e06ea..029c14640b7a 100644
--- a/third_party/nix/src/libstore/derivations.cc
+++ b/third_party/nix/src/libstore/derivations.cc
@@ -90,7 +90,7 @@ static string parseString(std::istream& str) {
 
 static Path parsePath(std::istream& str) {
   string s = parseString(str);
-  if (s.size() == 0 || s[0] != '/') {
+  if (s.empty() || s[0] != '/') {
     throw FormatError(format("bad path '%1%' in derivation") % s);
   }
   return s;
@@ -197,7 +197,7 @@ Derivation Store::derivationFromPath(const Path& drvPath) {
 
 static void printString(string& res, const string& s) {
   res += '"';
-  for (const char* i = s.c_str(); *i; i++) {
+  for (const char* i = s.c_str(); *i != 0; i++) {
     if (*i == '\"' || *i == '\\') {
       res += "\\";
       res += *i;
@@ -303,7 +303,7 @@ bool isDerivation(const string& fileName) {
 
 bool BasicDerivation::isFixedOutput() const {
   return outputs.size() == 1 && outputs.begin()->first == "out" &&
-         outputs.begin()->second.hash != "";
+         !outputs.begin()->second.hash.empty();
 }
 
 DrvHashes drvHashes;
@@ -356,10 +356,11 @@ Hash hashDerivationModulo(Store& store, Derivation drv) {
 
 DrvPathWithOutputs parseDrvPathWithOutputs(const string& s) {
   size_t n = s.find("!");
-  return n == s.npos ? DrvPathWithOutputs(s, std::set<string>())
-                     : DrvPathWithOutputs(string(s, 0, n),
-                                          tokenizeString<std::set<string> >(
-                                              string(s, n + 1), ","));
+  return n == std::string::npos
+             ? DrvPathWithOutputs(s, std::set<string>())
+             : DrvPathWithOutputs(
+                   string(s, 0, n),
+                   tokenizeString<std::set<string> >(string(s, n + 1), ","));
 }
 
 Path makeDrvPathWithOutputs(const Path& drvPath,