From ad787b20cad2962cf16a8d943292c84582267832 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 28 Nov 2022 10:41:19 -0500 Subject: nvdrv: Simplify builder declarations We can just use auto here. If one of these ever happens to not be derived from nvdevice, then this will cause a compilation error. We can also move the devices into the collection to get rid of an unnecessary atomic reference count increment and decrement. --- src/core/hle/service/nvdrv/nvdrv.cpp | 44 +++++++++++++++--------------------- 1 file changed, 18 insertions(+), 26 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index 9f4c7c99a..6fc8565c0 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -55,48 +55,40 @@ void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger Module::Module(Core::System& system) : container{system.Host1x()}, service_context{system, "nvdrv"}, events_interface{*this} { builders["/dev/nvhost-as-gpu"] = [this, &system](DeviceFD fd) { - std::shared_ptr device = - std::make_shared(system, *this, container); - return open_files.emplace(fd, device).first; + auto device = std::make_shared(system, *this, container); + return open_files.emplace(fd, std::move(device)).first; }; builders["/dev/nvhost-gpu"] = [this, &system](DeviceFD fd) { - std::shared_ptr device = - std::make_shared(system, events_interface, container); - return open_files.emplace(fd, device).first; + auto device = std::make_shared(system, events_interface, container); + return open_files.emplace(fd, std::move(device)).first; }; builders["/dev/nvhost-ctrl-gpu"] = [this, &system](DeviceFD fd) { - std::shared_ptr device = - std::make_shared(system, events_interface); - return open_files.emplace(fd, device).first; + auto device = std::make_shared(system, events_interface); + return open_files.emplace(fd, std::move(device)).first; }; builders["/dev/nvmap"] = [this, &system](DeviceFD fd) { - std::shared_ptr device = - std::make_shared(system, container); - return open_files.emplace(fd, device).first; + auto device = std::make_shared(system, container); + return open_files.emplace(fd, std::move(device)).first; }; builders["/dev/nvdisp_disp0"] = [this, &system](DeviceFD fd) { - std::shared_ptr device = - std::make_shared(system, container); - return open_files.emplace(fd, device).first; + auto device = std::make_shared(system, container); + return open_files.emplace(fd, std::move(device)).first; }; builders["/dev/nvhost-ctrl"] = [this, &system](DeviceFD fd) { - std::shared_ptr device = - std::make_shared(system, events_interface, container); - return open_files.emplace(fd, device).first; + auto device = std::make_shared(system, events_interface, container); + return open_files.emplace(fd, std::move(device)).first; }; builders["/dev/nvhost-nvdec"] = [this, &system](DeviceFD fd) { - std::shared_ptr device = - std::make_shared(system, container); - return open_files.emplace(fd, device).first; + auto device = std::make_shared(system, container); + return open_files.emplace(fd, std::move(device)).first; }; builders["/dev/nvhost-nvjpg"] = [this, &system](DeviceFD fd) { - std::shared_ptr device = std::make_shared(system); - return open_files.emplace(fd, device).first; + auto device = std::make_shared(system); + return open_files.emplace(fd, std::move(device)).first; }; builders["/dev/nvhost-vic"] = [this, &system](DeviceFD fd) { - std::shared_ptr device = - std::make_shared(system, container); - return open_files.emplace(fd, device).first; + auto device = std::make_shared(system, container); + return open_files.emplace(fd, std::move(device)).first; }; } -- cgit v1.2.3