Archived
This forum has been archived. Please start a new discussion on GitHub.
Expensive return by value
bambuk
in Help Center
I have a server-side method that returns a sequence to the client:
The C++ abstract class produced by slice2cpp dictates that GetPosition() returned vector<Position> by value which is expensive for bigger vectors.
Is it possible to return a smart pointer instead? If not, what other solutions exist?
sequence<Position> PositionList;
interface ServerOps {
PositionList GetPositions();
};
The C++ abstract class produced by slice2cpp dictates that GetPosition() returned vector<Position> by value which is expensive for bigger vectors.
Is it possible to return a smart pointer instead? If not, what other solutions exist?
0
Comments
-
If you can take advantage of "named return value optimization" (NRVO), this return copy will be optimized out.
If you can't, you could use AMD (asynchronous method dispatch) in your server for this operation. The "return" parameter becomes an "in" parameter on the AMD callback.
Best regards,
Bernard0 -
Note that this topic, and others, were covered in my article "Optimizing Performance of File Transfers " in http://www.zeroc.com/newsletter/issue20.pdf0
-
marc wrote: »You could wrap the sequence in a class:
sequence<Position> PositionList; class SharedPositionList { PostionList list; }; interface ServerOps { SharedPositionList GetPositions(); };
How does this help? A copy of the SharedPositionList will be returned which will contain a COPY of PositionList.0
