Optimizing long UHorizontalBox ?


I have to display a large number (~200) of horizontal lines containing numerous (~20) elements.

For the moment, i’m using a function that creates each line as a UHorizontalBox from scratch.
So it basically has this structure:

void MyClass::FillHB(UHorizontalBox* TargetHB)
  UEditableTextBox* Id_EditableText = NewObject<UEditableTextBox>(this);
  Id_EditableText->WidgetStyle = ...;

  UHorizontalBoxSlot* Id_EditableTextSlot = Cast<UHorizontalBoxSlot>(Id_EditableText->Slot);

This function contains that sort of code for about 20 elements (various editable texts, check boxes, etc).
And it is called 200 times to display the whole list.

This works very well for a small number of lines (<=50)
But when i try to display 100-200 lines, it takes about 1/2 second to display them all.

So i’d like to optimize a bit that process.

I could create a blueprint widget and load this BP for each line, but i’m afraid loading 200 times the BP from the disk will be as long as creating it all as i currently do (didn’t make the test though).

So i’d like to create my own horizontal box inheriting from UHorizontalBox, so i can prepare everything that is constant and just fill the variables in my large loop.

So i tried to create:

class YAG_API UMyHorizontalBox : public UHorizontalBox

And i’d like to prepare everything in the class constructor.

But when i use that sort of code:

// Id
Id_EditableText = ObjectInitializer.CreateDefaultSubobject<UEditableTextBox>(this, TEXT("Id_EditableText"));

It compiles but crashes the editor.

I could put all the code in the Initialize() function but again, not sure i’ll gain much compared to my current code, so i’d like to make it all happen in the constructor.
The idea is to do as less as possible during runtime.

Any idea of the right way to do it ?