Skip to content

Commit 437b9b9

Browse files
committed
Rename MemorySourceAccessor::File::Directory::{contents -> entries}
This matches the "NAR Listing" JSON format, and also helps distinguish from regular file contents. Why we want to match that will become clear in the next comments, when we will in fact use (variations of) this data type for NAR listings.
1 parent 5caebab commit 437b9b9

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/libstore-tests/references.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ TEST(references, scanForReferencesDeep)
9999
// Create an in-memory file system with various reference patterns
100100
auto accessor = make_ref<MemorySourceAccessor>();
101101
accessor->root = File::Directory{
102-
.contents{
102+
.entries{
103103
{
104104
// file1.txt: contains hash1
105105
"file1.txt",
@@ -125,7 +125,7 @@ TEST(references, scanForReferencesDeep)
125125
// subdir: a subdirectory
126126
"subdir",
127127
File::Directory{
128-
.contents{
128+
.entries{
129129
{
130130
// subdir/file4.txt: contains hash1 again
131131
"file4.txt",

src/libutil-tests/git.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ TEST_F(GitTest, both_roundrip)
230230

231231
auto files = make_ref<MemorySourceAccessor>();
232232
files->root = File::Directory{
233-
.contents{
233+
.entries{
234234
{
235235
"foo",
236236
File::Regular{
@@ -240,7 +240,7 @@ TEST_F(GitTest, both_roundrip)
240240
{
241241
"bar",
242242
File::Directory{
243-
.contents =
243+
.entries =
244244
{
245245
{
246246
"baz",

src/libutil/include/nix/util/memory-source-accessor.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct MemorySourceAccessor : virtual SourceAccessor
3535
{
3636
using Name = std::string;
3737

38-
std::map<Name, File, std::less<>> contents;
38+
std::map<Name, File, std::less<>> entries;
3939

4040
bool operator==(const Directory &) const noexcept;
4141
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
@@ -95,7 +95,7 @@ inline bool MemorySourceAccessor::File::Directory::operator==(
9595
inline bool
9696
MemorySourceAccessor::File::Directory::operator<(const MemorySourceAccessor::File::Directory & other) const noexcept
9797
{
98-
return contents < other.contents;
98+
return entries < other.entries;
9999
}
100100

101101
inline bool MemorySourceAccessor::File::operator==(const MemorySourceAccessor::File &) const noexcept = default;

src/libutil/memory-source-accessor.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ MemorySourceAccessor::File * MemorySourceAccessor::open(const CanonPath & path,
2929
return nullptr;
3030
auto & curDir = *curDirP;
3131

32-
auto i = curDir.contents.find(name);
33-
if (i == curDir.contents.end()) {
32+
auto i = curDir.entries.find(name);
33+
if (i == curDir.entries.end()) {
3434
if (!create)
3535
return nullptr;
3636
else {
3737
newF = true;
38-
i = curDir.contents.insert(
38+
i = curDir.entries.insert(
3939
i,
4040
{
4141
std::string{name},
@@ -106,7 +106,7 @@ MemorySourceAccessor::DirEntries MemorySourceAccessor::readDirectory(const Canon
106106
throw Error("file '%s' does not exist", path);
107107
if (auto * d = std::get_if<File::Directory>(&f->raw)) {
108108
DirEntries res;
109-
for (auto & [name, file] : d->contents)
109+
for (auto & [name, file] : d->entries)
110110
res.insert_or_assign(name, file.lstat().type);
111111
return res;
112112
} else

0 commit comments

Comments
 (0)