LibIPC: Give MessageBuffer::fds some inline capacity (1)

This dodges a heap allocation when sending 0 or 1 fd across the IPC
boundary (which covers every message.)
This commit is contained in:
Andreas Kling 2021-11-28 09:03:15 +01:00
parent 8608cd11e4
commit 86a3ef2709
Notes: sideshowbarker 2024-07-18 00:33:43 +09:00
2 changed files with 3 additions and 3 deletions

View file

@ -41,7 +41,7 @@ void ConnectionBase::post_message(MessageBuffer buffer)
#ifdef __serenity__
for (auto& fd : buffer.fds) {
auto rc = sendfd(m_socket->fd(), fd->value());
auto rc = sendfd(m_socket->fd(), fd.value());
if (rc < 0) {
perror("sendfd");
shutdown();

View file

@ -6,9 +6,9 @@
#pragma once
#include <AK/NonnullRefPtrVector.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/Vector.h>
#include <unistd.h>
namespace IPC {
@ -34,7 +34,7 @@ private:
struct MessageBuffer {
Vector<u8, 1024> data;
Vector<RefPtr<AutoCloseFileDescriptor>> fds;
NonnullRefPtrVector<AutoCloseFileDescriptor, 1> fds;
};
enum class ErrorCode : u32 {