Closed Laxilef closed 1 week ago
Hi @Laxilef,
The second and third getUpdates()
overloads won't create copies of the returned JsonDocument
because of the copy elision mechanism. Even if copy elision didn't trigger, JsonDocument
is move-contructible, so it would not produce a copy.
Passing by reference would work, too, but it would be less elegant.
Best regards, Benoit
Thanks!
Hi,
Question about optimization when returning
JsonDocument
from class methods. Let's say there is code:In the first
Bot::getUpdates()
method I create aJsonDocument
and the other methods are helpers. If I understand correctly, then every time theJsonDocument
will be copied at each nesting level and create an extra load? The problem is that there can be more nesting levels. Would it be more correct to passJsonDocument
by reference to a method or is there a more elegant way? Thank you!