]> git.seodisparate.com - blue_noise_generation/commitdiff
utility::Cleanup: Replace "Nop"
authorStephen Seo <seo.disparate@gmail.com>
Wed, 20 Mar 2024 10:18:37 +0000 (19:18 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Wed, 20 Mar 2024 10:18:37 +0000 (19:18 +0900)
A default constructor suffices where "Nop" was used, so it was removed.

src/blue_noise.cpp
src/utility.cpp
src/utility.hpp

index 2e1292e552feb7b62e4bd2323a6447f18f47968d..ffdec72cd65004be20af6d3284e4923a4ee80c7c 100644 (file)
@@ -456,8 +456,8 @@ image::Bl dither::blue_noise(int width, int height, int threads,
     // create compute pipeline.
     VkPipelineLayout compute_pipeline_layout;
     VkPipeline compute_pipeline;
-    utility::Cleanup cleanup_pipeline_layout(utility::Cleanup::Nop{});
-    utility::Cleanup cleanup_pipeline(utility::Cleanup::Nop{});
+    utility::Cleanup cleanup_pipeline_layout{};
+    utility::Cleanup cleanup_pipeline{};
     {
       VkShaderModuleCreateInfo shader_module_create_info{};
       shader_module_create_info.sType =
@@ -549,8 +549,8 @@ image::Bl dither::blue_noise(int width, int height, int threads,
 
     VkBuffer precomputed_buf;
     VkDeviceMemory precomputed_buf_mem;
-    utility::Cleanup cleanup_precomputed_buf(utility::Cleanup::Nop{});
-    utility::Cleanup cleanup_precomputed_buf_mem(utility::Cleanup::Nop{});
+    utility::Cleanup cleanup_precomputed_buf{};
+    utility::Cleanup cleanup_precomputed_buf_mem{};
     {
       VkBuffer staging_buffer;
       VkDeviceMemory staging_buffer_mem;
@@ -647,8 +647,8 @@ image::Bl dither::blue_noise(int width, int height, int threads,
 
     VkBuffer other_buf;
     VkDeviceMemory other_buf_mem;
-    utility::Cleanup cleanup_other_buf(utility::Cleanup::Nop{});
-    utility::Cleanup cleanup_other_buf_mem(utility::Cleanup::Nop{});
+    utility::Cleanup cleanup_other_buf{};
+    utility::Cleanup cleanup_other_buf_mem{};
     {
       VkBuffer staging_buffer;
       VkDeviceMemory staging_buffer_mem;
index ea72296753f917615acef073797377fcc4d2ce85..ea080939982df4f81868624c2606b62a58af3b86 100644 (file)
@@ -3,7 +3,7 @@
 utility::Cleanup::Cleanup(std::function<void(void *)> fn, void *ptr)
     : fn(fn), ptr(ptr) {}
 
-utility::Cleanup::Cleanup(Nop) : fn(), ptr(nullptr) {}
+utility::Cleanup::Cleanup() : fn(), ptr(nullptr) {}
 
 utility::Cleanup::~Cleanup() {
   if (this->fn.has_value()) {
index fe152bdfe6ffcc21cdea416ff31d25cb17a86a50..c9fa5ae62f6f0b8a6d4128a4eac33ad7bc2a5c67 100644 (file)
@@ -33,10 +33,8 @@ inline float dist(int a, int b, int width) {
 
 class Cleanup {
  public:
-  struct Nop {};
-
+  Cleanup();
   Cleanup(std::function<void(void *)> fn, void *ptr);
-  Cleanup(Nop nop);
   ~Cleanup();
 
   // allow move