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:
parent
8608cd11e4
commit
86a3ef2709
Notes:
sideshowbarker
2024-07-18 00:33:43 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/86a3ef27092
2 changed files with 3 additions and 3 deletions
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue