mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-14 01:04:38 +03:00
Kernel: Use move semantics in sys$sendfd()
Avoid an unnecessary NonnullRefPtr<OpenFileDescription> copy.
This commit is contained in:
parent
422d725c79
commit
b6efd66d56
Notes:
sideshowbarker
2024-07-18 03:55:11 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b6efd66d563
@ -466,7 +466,7 @@ NonnullRefPtrVector<OpenFileDescription>& LocalSocket::sendfd_queue_for(const Op
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
KResult LocalSocket::sendfd(const OpenFileDescription& socket_description, OpenFileDescription& passing_description)
|
||||
KResult LocalSocket::sendfd(OpenFileDescription const& socket_description, NonnullRefPtr<OpenFileDescription> passing_description)
|
||||
{
|
||||
MutexLocker locker(mutex());
|
||||
auto role = this->role(socket_description);
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
static KResultOr<SocketPair> try_create_connected_pair(int type);
|
||||
virtual ~LocalSocket() override;
|
||||
|
||||
KResult sendfd(const OpenFileDescription& socket_description, OpenFileDescription& passing_description);
|
||||
KResult sendfd(OpenFileDescription const& socket_description, NonnullRefPtr<OpenFileDescription> passing_description);
|
||||
KResultOr<NonnullRefPtr<OpenFileDescription>> recvfd(const OpenFileDescription& socket_description);
|
||||
|
||||
static void for_each(Function<void(const LocalSocket&)>);
|
||||
|
@ -23,9 +23,9 @@ KResultOr<FlatPtr> Process::sys$sendfd(int sockfd, int fd)
|
||||
if (!socket.is_connected())
|
||||
return ENOTCONN;
|
||||
|
||||
auto passing_descriptor = TRY(fds().open_file_description(fd));
|
||||
auto passing_description = TRY(fds().open_file_description(fd));
|
||||
auto& local_socket = static_cast<LocalSocket&>(socket);
|
||||
return local_socket.sendfd(*socket_description, *passing_descriptor);
|
||||
return local_socket.sendfd(*socket_description, move(passing_description));
|
||||
}
|
||||
|
||||
KResultOr<FlatPtr> Process::sys$recvfd(int sockfd, int options)
|
||||
|
Loading…
Reference in New Issue
Block a user