tp: move ColumnStorage creation to initializer instead of body
By doing this, we should reduce the binary size of the table
constructors signficantly as objects are not constantly created and
moved. Instead, we just directly can construct the object in place.
Bug: crbug/1341029
Change-Id: I522a2e8b9561499af403b1f142706ffb4bf68191
diff --git a/src/trace_processor/tables/macros_internal.h b/src/trace_processor/tables/macros_internal.h
index 8454a55..00b375d 100644
--- a/src/trace_processor/tables/macros_internal.h
+++ b/src/trace_processor/tables/macros_internal.h
@@ -402,9 +402,9 @@
PERFETTO_TP_PARENT_COLUMN_FLAG_NO_FLAG_COL)(__VA_ARGS__))
// Creates the sparse vector with the given flags.
-#define PERFETTO_TP_TABLE_CONSTRUCTOR_SV(type, name, ...) \
- name##_ = ColumnStorage<TypedColumn<type>::stored_type>::Create< \
- (name##_flags() & Column::Flag::kDense) != 0>();
+#define PERFETTO_TP_TABLE_CONSTRUCTOR_SV(type, name, ...) \
+ name##_(ColumnStorage<TypedColumn<type>::stored_type>::Create< \
+ (name##_flags() & Column::Flag::kDense) != 0>()),
// Invokes the chosen column constructor by passing the given args.
#define PERFETTO_TP_TABLE_CONSTRUCTOR_COLUMN(type, name, ...) \
@@ -755,20 +755,15 @@
}; \
\
class_name(StringPool* pool, parent_class_name* parent) \
- : macros_internal::MacroTable(pool, parent), parent_(parent) { \
+ : macros_internal::MacroTable(pool, parent), \
+ PERFETTO_TP_TABLE_COLUMNS(DEF, PERFETTO_TP_TABLE_CONSTRUCTOR_SV) \
+ parent_(parent) { \
PERFETTO_CHECK(kIsRootTable == (parent == nullptr)); \
\
PERFETTO_TP_ALL_COLUMNS(DEF, PERFETTO_TP_TABLE_STATIC_ASSERT_FLAG) \
\
/* \
* Expands to \
- * col1_ = NullableVector<col1_type>(mode) \
- * ... \
- */ \
- PERFETTO_TP_TABLE_COLUMNS(DEF, PERFETTO_TP_TABLE_CONSTRUCTOR_SV); \
- \
- /* \
- * Expands to \
* columns_.emplace_back("col1", col1_, Column::kNoFlag, this, \
* static_cast<uint32_t>(columns_.size()), \
* static_cast<uint32_t>(row_maps_.size()) - 1); \
@@ -934,14 +929,14 @@
PERFETTO_TP_TABLE_COLUMNS(DEF, PERFETTO_TP_TABLE_CONSTRUCTOR_COLUMN); \
} \
\
- parent_class_name* parent_ = nullptr; \
- \
/* \
* Expands to \
* NullableVector<col1_type> col1_; \
* ... \
*/ \
PERFETTO_TP_TABLE_COLUMNS(DEF, PERFETTO_TP_TABLE_MEMBER) \
+ \
+ parent_class_name* parent_ = nullptr; \
}
} // namespace trace_processor