src.ctf.fs: remove ctf_fs_ds_file_group_create, add constructor
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 21 Jun 2022 19:33:10 +0000 (15:33 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 23 Aug 2022 16:06:16 +0000 (12:06 -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>
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 eca2fee9d65a0604a62e83b83ecd039713a5c0a1..e5b9791b8f482d1f25949859f71d72c12fbf889d 100644 (file)
@@ -738,23 +738,6 @@ BT_HIDDEN ctf_fs_ds_file_info::UP ctf_fs_ds_file_info_create(const char *path, i
     return ds_file_info;
 }
 
-BT_HIDDEN 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. */
@@ -769,4 +752,4 @@ void ctf_fs_ds_file_group::insert_ds_file_info_sorted(ctf_fs_ds_file_info::UP ds
     }
 
     this->ds_file_infos.insert(it, std::move(ds_file_info));
-}
\ No newline at end of file
+}
index 4c863c330494f3afbc931f989096a7c4ec31a801..e1e7aa59307ee8f847dfdc4826fdc76ff576d95b 100644 (file)
@@ -124,6 +124,15 @@ struct ctf_fs_ds_file_group
 {
     using UP = std::unique_ptr<ctf_fs_ds_file_group>;
 
+    ctf_fs_ds_file_group(struct ctf_fs_trace *ctfFsTrace, struct ctf_stream_class *scParam,
+                         uint64_t streamInstanceId, ctf_fs_ds_index indexParam) :
+
+        sc {scParam},
+        stream_id(streamInstanceId), ctf_fs_trace {ctfFsTrace}, index {std::move(indexParam)}
+
+    {
+    }
+
     /*
     * Insert ds_file_info in the list of ds_file_infos at the right
     * place to keep it sorted.
@@ -166,11 +175,6 @@ ctf_fs_ds_file_build_index(struct ctf_fs_ds_file *ds_file, struct ctf_fs_ds_file
 
 BT_HIDDEN ctf_fs_ds_file_info::UP ctf_fs_ds_file_info_create(const char *path, int64_t begin_ns);
 
-BT_HIDDEN 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 cfc3b04aff3aa8a8401ad3fc55a85a8095c27658..ec21795aa07abdba44ce8c7e2d6e00f73b9dfca2 100644 (file)
@@ -494,12 +494,8 @@ 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.
          */
-        ctf_fs_ds_file_group::UP 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;
-        }
+        ctf_fs_ds_file_group::UP new_ds_file_group = bt2_common::makeUnique<ctf_fs_ds_file_group>(
+            ctf_fs_trace, sc, UINT64_C(-1), std::move(*index));
 
         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));
@@ -518,15 +514,9 @@ 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;
-        }
-
+        ctf_fs_ds_file_group::UP new_ds_file_group = bt2_common::makeUnique<ctf_fs_ds_file_group>(
+            ctf_fs_trace, sc, (uint64_t) stream_instance_id, std::move(*index));
         ds_file_group = new_ds_file_group.get();
         ctf_fs_trace->ds_file_groups.emplace_back(std::move(new_ds_file_group));
     } else {
@@ -811,13 +801,8 @@ 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);
 
-            ctf_fs_ds_file_group::UP new_dest_group =
-                ctf_fs_ds_file_group_create(dest_trace, sc, src_group->stream_id, {});
-            /* Ownership of index is transferred. */
-            if (!new_dest_group) {
-                return -1;
-            }
-
+            ctf_fs_ds_file_group::UP new_dest_group = bt2_common::makeUnique<ctf_fs_ds_file_group>(
+                dest_trace, sc, src_group->stream_id, ctf_fs_ds_index {});
             dest_group = new_dest_group.get();
             dest_trace->ds_file_groups.emplace_back(std::move(new_dest_group));
         }
This page took 0.028361 seconds and 5 git commands to generate.