From 8cd3d9be2646eda7177344045984f2baf9520ad3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 23 May 2019 13:32:49 -0400 Subject: [PATCH] common/file_util: Make IOFile's WriteString take a std::string_view We don't need to force the usage of a std::string here, and can instead use a std::string_view, which allows writing out other forms of strings (e.g. C-style strings) without any unnecessary heap allocations. --- src/common/file_util.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/file_util.h b/src/common/file_util.h index 38cc7f059c..cd5a0c5fce 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -257,8 +257,8 @@ public: return WriteArray(&object, 1); } - std::size_t WriteString(const std::string& str) { - return WriteArray(str.c_str(), str.length()); + std::size_t WriteString(std::string_view str) { + return WriteArray(str.data(), str.length()); } bool IsOpen() const {