From 0a48146efcf9654b57bd8f02865b82e6e545cb02 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 22 Oct 2021 11:53:50 +0200 Subject: [PATCH] client/Client: pass std::string_view to Write() Almost all callers have string literal, and the length is known at compile time. --- src/client/Client.hxx | 4 +++- src/client/Write.cxx | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/client/Client.hxx b/src/client/Client.hxx index c182eb6b5..5f9c6d10e 100644 --- a/src/client/Client.hxx +++ b/src/client/Client.hxx @@ -150,7 +150,9 @@ public: /** * Write a null-terminated string. */ - bool Write(const char *data) noexcept; + bool Write(std::string_view s) noexcept { + return Write(s.data(), s.size()); + } /** * returns the uid of the client process, or a negative value diff --git a/src/client/Write.cxx b/src/client/Write.cxx index ab008bc53..170980eaa 100644 --- a/src/client/Write.cxx +++ b/src/client/Write.cxx @@ -27,9 +27,3 @@ Client::Write(const void *data, size_t length) noexcept /* if the client is going to be closed, do nothing */ return !IsExpired() && FullyBufferedSocket::Write(data, length); } - -bool -Client::Write(const char *data) noexcept -{ - return Write(data, strlen(data)); -}