Skip to content

Commit 4ab6f22

Browse files
authored
Merge pull request #632 from smarsching/xvc-client-performance
Performance improvement for XVC client
2 parents 21d2e46 + 485d971 commit 4ab6f22

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/xvc_client.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -267,20 +267,16 @@ ssize_t XVC_client::xfer_pkt(const string &instr,
267267
uint8_t *rx, uint32_t rx_size)
268268
{
269269
ssize_t len = tx_size;
270+
vector<uint8_t> buffer(instr.size() + (tx) ? tx_size : 0);
271+
memcpy(buffer.data(), instr.c_str(), instr.size());
272+
if (tx)
273+
memcpy(buffer.data() + instr.size(), tx, tx_size);
270274

271-
/* 1. instruction */
272-
if (sendall(_sock, instr.c_str(), instr.size(), 0) == -1) {
273-
printError("Send instruction failed");
275+
if (sendall(_sock, buffer.data(), buffer.size(), 0) == -1) {
276+
printError("Send failed");
274277
return -1;
275278
}
276279

277-
if (tx) {
278-
if (sendall(_sock, tx, tx_size, 0) == -1) {
279-
printError("Send error");
280-
return -1;
281-
}
282-
}
283-
284280
if (rx) {
285281
len = recv(_sock, rx, rx_size, 0);
286282
if (len < 0) {

0 commit comments

Comments
 (0)