fs/archive: Make use of std::make_shared where applicable (#5319)

Allows implementations to allocate the object and the shared_ptr control
block in one allocation instead of needing to do two separate
allocations.

Also looks much nicer to the reader.
This commit is contained in:
Mat M 2020-05-04 06:22:13 -04:00 committed by GitHub
parent 79536ddb11
commit 6e48149ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,7 +91,7 @@ ArchiveManager::OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys:
if (backend.Failed())
return std::make_tuple(backend.Code(), open_timeout_ns);
auto file = std::shared_ptr<File>(new File(system.Kernel(), std::move(backend).Unwrap(), path));
auto file = std::make_shared<File>(system.Kernel(), std::move(backend).Unwrap(), path);
return std::make_tuple(MakeResult<std::shared_ptr<File>>(std::move(file)), open_timeout_ns);
}
@ -184,7 +184,7 @@ ResultVal<std::shared_ptr<Directory>> ArchiveManager::OpenDirectoryFromArchive(
if (backend.Failed())
return backend.Code();
auto directory = std::shared_ptr<Directory>(new Directory(std::move(backend).Unwrap(), path));
auto directory = std::make_shared<Directory>(std::move(backend).Unwrap(), path);
return MakeResult<std::shared_ptr<Directory>>(std::move(directory));
}