mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
dont use string_view
I don't like that it's implicitly constructible from a const char *, and assumes it's 0-terminated. so void * it is.
This commit is contained in:
parent
04620f1565
commit
db55fdf73f
4 changed files with 5 additions and 7 deletions
|
@ -37,14 +37,14 @@ TEST_CASE("benchmark_ipc_channel")
|
||||||
auto thread_b = std::move(end_a_thread_b_p.second);
|
auto thread_b = std::move(end_a_thread_b_p.second);
|
||||||
|
|
||||||
BENCHMARK("simple_call_1", i) {
|
BENCHMARK("simple_call_1", i) {
|
||||||
char buf[16] = {};
|
u8 buf[16] = {};
|
||||||
buf[i & 0xf] = i;
|
buf[i & 0xf] = i;
|
||||||
end_a.exchange(buf, 16);
|
end_a.exchange(buf, 16);
|
||||||
return reinterpret_cast<const u8 *>(end_a.getRecvData())[i & 0xf];
|
return reinterpret_cast<const u8 *>(end_a.getRecvData())[i & 0xf];
|
||||||
};
|
};
|
||||||
|
|
||||||
BENCHMARK("simple_call_1000", i) {
|
BENCHMARK("simple_call_1000", i) {
|
||||||
char buf[16] = {};
|
u8 buf[16] = {};
|
||||||
buf[i & 0xf] = i;
|
buf[i & 0xf] = i;
|
||||||
for (int k = 0; k < 1000; ++k) {
|
for (int k = 0; k < 1000; ++k) {
|
||||||
buf[0] = k & 0xff;
|
buf[0] = k & 0xff;
|
||||||
|
|
|
@ -302,7 +302,7 @@ bool IPCChannelEnd::sendLarge(const void *data, size_t size, int timeout_ms) noe
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
size -= IPC_CHANNEL_MSG_SIZE;
|
size -= IPC_CHANNEL_MSG_SIZE;
|
||||||
data = (u8 *)data + IPC_CHANNEL_MSG_SIZE;
|
data = reinterpret_cast<const u8 *>(data) + IPC_CHANNEL_MSG_SIZE;
|
||||||
} while (size > IPC_CHANNEL_MSG_SIZE);
|
} while (size > IPC_CHANNEL_MSG_SIZE);
|
||||||
|
|
||||||
if (size != 0)
|
if (size != 0)
|
||||||
|
|
|
@ -236,7 +236,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the content of the last received message
|
// Get the content of the last received message
|
||||||
// TODO: u8 *, or string_view?
|
|
||||||
const void *getRecvData() const noexcept { return m_large_recv.data(); }
|
const void *getRecvData() const noexcept { return m_large_recv.data(); }
|
||||||
size_t getRecvSize() const noexcept { return m_recv_size; }
|
size_t getRecvSize() const noexcept { return m_recv_size; }
|
||||||
|
|
||||||
|
@ -245,7 +244,6 @@ private:
|
||||||
m_resources(std::move(resources)), m_dir(dir)
|
m_resources(std::move(resources)), m_dir(dir)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// TODO: u8 *, or string_view?
|
|
||||||
void sendSmall(const void *data, size_t size) noexcept;
|
void sendSmall(const void *data, size_t size) noexcept;
|
||||||
|
|
||||||
// returns false on timeout
|
// returns false on timeout
|
||||||
|
|
|
@ -243,12 +243,12 @@ void TestThreading::testIPCChannel()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
char buf[20000] = {};
|
u8 buf[20000] = {};
|
||||||
for (int i = sizeof(buf); i > 0; i -= 100) {
|
for (int i = sizeof(buf); i > 0; i -= 100) {
|
||||||
buf[i - 1] = 123;
|
buf[i - 1] = 123;
|
||||||
UASSERT(end_a.exchangeWithTimeout(buf, i, -1));
|
UASSERT(end_a.exchangeWithTimeout(buf, i, -1));
|
||||||
UASSERTEQ(int, end_a.getRecvSize(), i);
|
UASSERTEQ(int, end_a.getRecvSize(), i);
|
||||||
UASSERTEQ(int, ((const char *)end_a.getRecvData())[i - 1], 123);
|
UASSERTEQ(int, reinterpret_cast<const u8 *>(end_a.getRecvData())[i - 1], 123);
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop thread_b
|
// stop thread_b
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue