src.ctf.fs: remove ctf_fs_ds_file_group_create, add constructor
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 10 Apr 2024 03:31:37 +0000 (23:31 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Replace ctf_fs_ds_file_group_create with an equivalent constructor.

Change-Id: I06d69a05ba685552dc2d6b78800d79f20569a340
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8435
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12360
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/fs-src/data-stream-file.cpp
src/plugins/ctf/fs-src/data-stream-file.hpp
src/plugins/ctf/fs-src/fs.cpp

index 73c896a99fed0eca8453362d95681de9492c9186..e4bebf9f68015af8147928f1d3046ff2fcafd3ef 100644 (file)
@@ -729,23 +729,6 @@ ctf_fs_ds_file_info::UP ctf_fs_ds_file_info_create(const char *path, int64_t beg
     return ds_file_info;
 }
 
-ctf_fs_ds_file_group::UP ctf_fs_ds_file_group_create(struct ctf_fs_trace *ctf_fs_trace,
-                                                     struct ctf_stream_class *sc,
-                                                     uint64_t stream_instance_id,
-                                                     ctf_fs_ds_index index)
-{
-    ctf_fs_ds_file_group::UP ds_file_group {new ctf_fs_ds_file_group};
-
-    ds_file_group->index = std::move(index);
-
-    ds_file_group->stream_id = stream_instance_id;
-    BT_ASSERT(sc);
-    ds_file_group->sc = sc;
-    ds_file_group->ctf_fs_trace = ctf_fs_trace;
-
-    return ds_file_group;
-}
-
 void ctf_fs_ds_file_group::insert_ds_file_info_sorted(ctf_fs_ds_file_info::UP ds_file_info)
 {
     /* Find the spot where to insert this ds_file_info. */
index f27dbde701206202f33ebb06c0da08d80101bbaa..e00a5cc43831447b9819cea817657b5434e01792 100644 (file)
@@ -121,6 +121,16 @@ struct ctf_fs_ds_file_group
 {
     using UP = std::unique_ptr<ctf_fs_ds_file_group>;
 
+    explicit ctf_fs_ds_file_group(struct ctf_fs_trace * const trace,
+                                  ctf_stream_class * const scParam, const uint64_t streamInstanceId,
+                                  ctf_fs_ds_index indexParam) noexcept :
+
+        sc {scParam},
+        stream_id(streamInstanceId), ctf_fs_trace {trace}, index {std::move(indexParam)}
+
+    {
+    }
+
     /*
      * Insert ds_file_info in the list of ds_file_infos at the right
      * place to keep it sorted.
@@ -159,11 +169,6 @@ bt2s::optional<ctf_fs_ds_index> ctf_fs_ds_file_build_index(struct ctf_fs_ds_file
 
 ctf_fs_ds_file_info::UP ctf_fs_ds_file_info_create(const char *path, int64_t begin_ns);
 
-ctf_fs_ds_file_group::UP ctf_fs_ds_file_group_create(struct ctf_fs_trace *ctf_fs_trace,
-                                                     struct ctf_stream_class *sc,
-                                                     uint64_t stream_instance_id,
-                                                     ctf_fs_ds_index index);
-
 /*
  * Medium operations to iterate on a single ctf_fs_ds_file.
  *
index 02cf97df32426d5c74b2d12b68de992e7ca3b52a..09f663e342b2d739944cf594ad0204a94fb7b688 100644 (file)
@@ -470,15 +470,9 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
          * there's no timestamp to order the file within its
          * group.
          */
-        auto new_ds_file_group =
-            ctf_fs_ds_file_group_create(ctf_fs_trace, sc, UINT64_C(-1), std::move(*index));
-
-        if (!new_ds_file_group) {
-            return -1;
-        }
-
-        new_ds_file_group->insert_ds_file_info_sorted(std::move(ds_file_info));
-        ctf_fs_trace->ds_file_groups.emplace_back(std::move(new_ds_file_group));
+        ctf_fs_trace->ds_file_groups.emplace_back(bt2s::make_unique<ctf_fs_ds_file_group>(
+            ctf_fs_trace, sc, UINT64_C(-1), std::move(*index)));
+        ctf_fs_trace->ds_file_groups.back()->insert_ds_file_info_sorted(std::move(ds_file_info));
         return 0;
     }
 
@@ -494,17 +488,10 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
         }
     }
 
-    ctf_fs_ds_file_group::UP new_ds_file_group;
-
     if (!ds_file_group) {
-        new_ds_file_group =
-            ctf_fs_ds_file_group_create(ctf_fs_trace, sc, stream_instance_id, std::move(*index));
-        if (!new_ds_file_group) {
-            return -1;
-        }
-
-        ds_file_group = new_ds_file_group.get();
-        ctf_fs_trace->ds_file_groups.emplace_back(std::move(new_ds_file_group));
+        ctf_fs_trace->ds_file_groups.emplace_back(bt2s::make_unique<ctf_fs_ds_file_group>(
+            ctf_fs_trace, sc, static_cast<std::uint64_t>(stream_instance_id), std::move(*index)));
+        ds_file_group = ctf_fs_trace->ds_file_groups.back().get();
     } else {
         merge_ctf_fs_ds_indexes(ds_file_group->index, *index);
     }
@@ -786,15 +773,9 @@ static int merge_matching_ctf_fs_ds_file_groups(struct ctf_fs_trace *dest_trace,
                 dest_trace->metadata->tc, src_group->sc->id);
             BT_ASSERT(sc);
 
-            auto new_dest_group =
-                ctf_fs_ds_file_group_create(dest_trace, sc, src_group->stream_id, {});
-
-            if (!new_dest_group) {
-                return -1;
-            }
-
-            dest_group = new_dest_group.get();
-            dest_trace->ds_file_groups.emplace_back(std::move(new_dest_group));
+            dest_trace->ds_file_groups.emplace_back(bt2s::make_unique<ctf_fs_ds_file_group>(
+                dest_trace, sc, src_group->stream_id, ctf_fs_ds_index {}));
+            dest_group = dest_trace->ds_file_groups.back().get();
         }
 
         BT_ASSERT(dest_group);
This page took 0.026708 seconds and 4 git commands to generate.