Enhancement #2050

Updated by J. Moringen over 6 years ago

Hi Sebastian and all,

Why did you decided to pass data to converters by ref instead of shared_ptr?
This requires to copy data over and over. Instead one could easily also pass the shared_ptr,
e.g. in source:rsb-cpp|src/rsb/transport/socket/InPullConnector.cpp#L90:

<pre><code class="cpp">
source:rsb-cpp/src/rsb/transport/socket/InPullConnector.cpp#L90:

boost::shared_ptr<string> wireData = static_pointer_cast<string>(event->getData());
string wireSchema = event->getMetaData().getUserInfo("rsb.wire-schema");
AnnotatedData d = getConverter(wireSchema)->deserialize(wireSchema, *wireData);
</code></pre>


and then reuse the pointer instead of reallocating, e.g. in source:rsb-cpp/src/rsb/converters/ByteArrayConverter.cpp#L49:

<pre><code class="cpp">


AnnotatedData ByteArrayConverter::deserialize(const std::string& /*wireSchema*/,
const string& wire) {
return make_pair(getDataType(), boost::shared_ptr<string>(new string(wire)));
}
</code></pre>

Back