diff options
Diffstat (limited to 'nix/libstore/references.cc')
| -rw-r--r-- | nix/libstore/references.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/nix/libstore/references.cc b/nix/libstore/references.cc index 282b848938b..d9c8a9fbe38 100644 --- a/nix/libstore/references.cc +++ b/nix/libstore/references.cc | |||
| @@ -13,7 +13,7 @@ namespace nix { | |||
| 13 | static unsigned int refLength = 32; /* characters */ | 13 | static unsigned int refLength = 32; /* characters */ |
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | static void search(const unsigned char * s, unsigned int len, | 16 | static void search(const unsigned char * s, unsigned int len, |
| 17 | StringSet & hashes, StringSet & seen) | 17 | StringSet & hashes, StringSet & seen) |
| 18 | { | 18 | { |
| 19 | static bool initialised = false; | 19 | static bool initialised = false; |
| @@ -24,7 +24,7 @@ static void search(const unsigned char * s, unsigned int len, | |||
| 24 | isBase32[(unsigned char) base32Chars[i]] = true; | 24 | isBase32[(unsigned char) base32Chars[i]] = true; |
| 25 | initialised = true; | 25 | initialised = true; |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | for (unsigned int i = 0; i + refLength <= len; ) { | 28 | for (unsigned int i = 0; i + refLength <= len; ) { |
| 29 | int j; | 29 | int j; |
| 30 | bool match = true; | 30 | bool match = true; |
| @@ -56,7 +56,7 @@ struct RefScanSink : Sink | |||
| 56 | string tail; | 56 | string tail; |
| 57 | 57 | ||
| 58 | RefScanSink() : hashSink(htSHA256) { } | 58 | RefScanSink() : hashSink(htSHA256) { } |
| 59 | 59 | ||
| 60 | void operator () (const unsigned char * data, size_t len); | 60 | void operator () (const unsigned char * data, size_t len); |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| @@ -89,17 +89,17 @@ PathSet scanForReferences(const string & path, | |||
| 89 | /* For efficiency (and a higher hit rate), just search for the | 89 | /* For efficiency (and a higher hit rate), just search for the |
| 90 | hash part of the file name. (This assumes that all references | 90 | hash part of the file name. (This assumes that all references |
| 91 | have the form `HASH-bla'). */ | 91 | have the form `HASH-bla'). */ |
| 92 | foreach (PathSet::const_iterator, i, refs) { | 92 | for (const auto& i : refs) { |
| 93 | string baseName = baseNameOf(*i); | 93 | string baseName = baseNameOf(i); |
| 94 | string::size_type pos = baseName.find('-'); | 94 | string::size_type pos = baseName.find('-'); |
| 95 | if (pos == string::npos) | 95 | if (pos == string::npos) |
| 96 | throw Error(format("bad reference `%1%'") % *i); | 96 | throw Error(format("bad reference `%1%'") % i); |
| 97 | string s = string(baseName, 0, pos); | 97 | string s = string(baseName, 0, pos); |
| 98 | assert(s.size() == refLength); | 98 | assert(s.size() == refLength); |
| 99 | assert(backMap.find(s) == backMap.end()); | 99 | assert(backMap.find(s) == backMap.end()); |
| 100 | // parseHash(htSHA256, s); | 100 | // parseHash(htSHA256, s); |
| 101 | sink.hashes.insert(s); | 101 | sink.hashes.insert(s); |
| 102 | backMap[s] = *i; | 102 | backMap[s] = i; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | /* Look for the hashes in the NAR dump of the path. */ | 105 | /* Look for the hashes in the NAR dump of the path. */ |
| @@ -107,14 +107,14 @@ PathSet scanForReferences(const string & path, | |||
| 107 | 107 | ||
| 108 | /* Map the hashes found back to their store paths. */ | 108 | /* Map the hashes found back to their store paths. */ |
| 109 | PathSet found; | 109 | PathSet found; |
| 110 | foreach (StringSet::iterator, i, sink.seen) { | 110 | for (auto& i : sink.seen) { |
| 111 | std::map<string, Path>::iterator j; | 111 | std::map<string, Path>::iterator j; |
| 112 | if ((j = backMap.find(*i)) == backMap.end()) abort(); | 112 | if ((j = backMap.find(i)) == backMap.end()) abort(); |
| 113 | found.insert(j->second); | 113 | found.insert(j->second); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | hash = sink.hashSink.finish(); | 116 | hash = sink.hashSink.finish(); |
| 117 | 117 | ||
| 118 | return found; | 118 | return found; |
| 119 | } | 119 | } |
| 120 | 120 | ||
