mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
htc: optimize Mux::QuerySendPacket
This commit is contained in:
parent
00ab210e66
commit
968ce12492
1 changed files with 11 additions and 15 deletions
|
@ -81,24 +81,20 @@ namespace ams::htclow::mux {
|
||||||
/* Lock ourselves. */
|
/* Lock ourselves. */
|
||||||
std::scoped_lock lk(m_mutex);
|
std::scoped_lock lk(m_mutex);
|
||||||
|
|
||||||
/* Get our map. */
|
/* Check for an error packet. */
|
||||||
auto &map = m_channel_impl_map.GetMap();
|
/* NOTE: Nintendo checks this once per iteration of the below loop. */
|
||||||
|
/* The extra checks are unnecessary, because we hold our mutex. */
|
||||||
|
if (auto *error_packet = m_global_send_buffer.GetNextPacket(); error_packet != nullptr) {
|
||||||
|
std::memcpy(header, error_packet->GetHeader(), sizeof(*header));
|
||||||
|
*out_body_size = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Iterate the map, checking for valid packet each time. */
|
/* Iterate the map, checking each channel for a valid valid packet. */
|
||||||
for (auto &pair : map) {
|
for (auto &pair : m_channel_impl_map.GetMap()) {
|
||||||
/* Get the current channel impl. */
|
/* Get the current channel impl. */
|
||||||
auto &channel_impl = m_channel_impl_map[pair.second];
|
|
||||||
|
|
||||||
/* Check for an error packet. */
|
|
||||||
/* NOTE: it's unclear why Nintendo does this every iteration of the loop... */
|
|
||||||
if (auto *error_packet = m_global_send_buffer.GetNextPacket(); error_packet != nullptr) {
|
|
||||||
std::memcpy(header, error_packet->GetHeader(), sizeof(*header));
|
|
||||||
*out_body_size = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* See if the channel has something for us to send. */
|
/* See if the channel has something for us to send. */
|
||||||
if (channel_impl.QuerySendPacket(header, body, out_body_size)) {
|
if (m_channel_impl_map[pair.second].QuerySendPacket(header, body, out_body_size)) {
|
||||||
return this->IsSendable(header->packet_type);
|
return this->IsSendable(header->packet_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue