Skip to content

Commit 4f2e5d7

Browse files
committed
optimize message::list conversion constructor.
1 parent c005a87 commit 4f2e5d7

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/sio_message.h

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,21 @@ namespace sio
151151
:message(flag_string),_v(v)
152152
{
153153
}
154+
155+
string_message(string&& v)
156+
:message(flag_string),_v(move(v))
157+
{
158+
}
154159
public:
155160
static message::ptr create(string const& v)
156161
{
157162
return ptr(new string_message(v));
158163
}
164+
165+
static message::ptr create(string&& v)
166+
{
167+
return ptr(new string_message(move(v)));
168+
}
159169

160170
string const& get_string() const
161171
{
@@ -258,15 +268,20 @@ namespace sio
258268
m_vector.push_back(message);
259269
}
260270

261-
list(string& text)
271+
list(const string& text)
262272
{
263273
m_vector.push_back(string_message::create(text));
264274
}
265275

266-
list(const char* text)
276+
list(string&& text)
267277
{
268-
if(text)
269-
m_vector.push_back(string_message::create(text));
278+
m_vector.push_back(string_message::create(move(text)));
279+
}
280+
281+
list(shared_ptr<string> const& binary)
282+
{
283+
if(binary)
284+
m_vector.push_back(binary_message::create(binary));
270285
}
271286

272287
list(shared_ptr<const string> const& binary)

0 commit comments

Comments
 (0)