C++ client ValueObject with Hashtable / copy

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(2,4); ValueObject vo = ValueObject(*ht); // here
According to template ValueObject.h, we are going to match this constructor:
ValueObject(typename Helpers::ConfirmAllowed::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.


  • 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 upwards.
Sign In or Register to comment.