|
2 | 2 | #include "api_config.h" |
3 | 3 | #include "resolver_impl.h" |
4 | 4 | #include "socket_utils.h" |
| 5 | +#include "util/strfuns.hpp" |
5 | 6 | #include <boost/asio/io_context.hpp> |
6 | 7 | #include <boost/asio/ip/address.hpp> |
7 | 8 | #include <boost/asio/ip/multicast.hpp> |
@@ -102,16 +103,16 @@ void resolve_attempt_udp::handle_receive_outcome(err_t err, std::size_t len) { |
102 | 103 | if (!err) { |
103 | 104 | try { |
104 | 105 | // first parse & check the query id |
105 | | - std::istringstream is(std::string(resultbuf_, len)); |
106 | | - std::string returned_id; |
107 | | - getline(is, returned_id); |
108 | | - returned_id = trim(returned_id); |
109 | | - if (returned_id == query_id_) { |
| 106 | + char *bufend = resultbuf_ + len; |
| 107 | + char *newlinepos = resultbuf_; |
| 108 | + // find the end of the line |
| 109 | + while (newlinepos != bufend && *newlinepos != '\n') ++newlinepos; |
| 110 | + std::string returned_id(resultbuf_, trim_end(resultbuf_, newlinepos)); |
| 111 | + |
| 112 | + if (returned_id == query_id_ && newlinepos != bufend) { |
110 | 113 | // parse the rest of the query into a stream_info |
111 | 114 | stream_info_impl info; |
112 | | - std::ostringstream os; |
113 | | - os << is.rdbuf(); |
114 | | - info.from_shortinfo_message(os.str()); |
| 115 | + info.from_shortinfo_message(std::string(newlinepos, bufend)); |
115 | 116 | std::string uid = info.uid(); |
116 | 117 | { |
117 | 118 | // update the results |
|
0 commit comments