C++ client ValueObject with Hashtable / copy

Options
Hi,
I made a few search to create a ValueObject with an Hashtable (same for Dictionary or JString...), but it seems like the original object is copied 2 times.
Is this a "normal" behaviour? If the hash is quite big, copying 2 time will be bad for performance.
Let's see what I mean:
Hashtable *ht = new Hastable; ht->put<int,int>(2,4); ValueObject<Hashtable> vo = ValueObject<Hashtable>(*ht); // here
According to template ValueObject.h, we are going to match this constructor:
ValueObject(typename Helpers::ConfirmAllowed<Etype>::type data);
with type Hastable. So the object is copied once, and this is not by reference (&). It is ok for simple type as char, int by object such as Hashtable, Dictionary or JString will be copied for nothing I think, or maybe I am missing something?

Then, the object is copied a second time when the deep copy of the object occurred.

Comments

  • Kaiserludi
    Options
    Hi @Kumamon.

    Nice find.

    Thank you for pointing us to this.

    You are right. That is indeed an unnecessary redundant copy that could negatively affect performance for bigger data without any benefit.

    We have optimized this and some other similar cases in the code and the optimizations will become available with 4.1.7.0 upwards.