Core/Log: Pass string_view by value instead of ref

This commit is contained in:
SirLynix 2023-02-22 19:04:07 +01:00
parent e96204a2ab
commit b38f9dc79b
10 changed files with 18 additions and 18 deletions

View File

@ -26,8 +26,8 @@ namespace Nz
virtual bool IsStdReplicationEnabled() const = 0;
virtual void Write(const std::string_view& string) = 0;
virtual void WriteError(ErrorType type, const std::string_view& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr);
virtual void Write(std::string_view string) = 0;
virtual void WriteError(ErrorType type, std::string_view error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr);
AbstractLogger& operator=(const AbstractLogger&) = default;
AbstractLogger& operator=(AbstractLogger&&) noexcept = default;

View File

@ -29,8 +29,8 @@ namespace Nz
bool IsStdReplicationEnabled() const override;
bool IsTimeLoggingEnabled() const;
void Write(const std::string_view& string) override;
void WriteError(ErrorType type, const std::string_view& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override;
void Write(std::string_view string) override;
void WriteError(ErrorType type, std::string_view error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override;
FileLogger& operator=(const FileLogger&) = delete;
FileLogger& operator=(FileLogger&&) = default;

View File

@ -39,8 +39,8 @@ namespace Nz
static void SetLogger(AbstractLogger* logger);
static void Write(const std::string_view& string);
static void WriteError(ErrorType type, const std::string_view& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr);
static void Write(std::string_view string);
static void WriteError(ErrorType type, std::string_view error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr);
NazaraStaticSignal(OnLogWrite, const std::string_view& /*string*/);
NazaraStaticSignal(OnLogWriteError, ErrorType /*type*/, const std::string_view& /*error*/, unsigned int /*line*/, const char* /*file*/, const char* /*function*/);

View File

@ -24,8 +24,8 @@ namespace Nz
bool IsStdReplicationEnabled() const override;
void Write(const std::string_view& error) override;
void WriteError(ErrorType type, const std::string_view& error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override;
void Write(std::string_view string) override;
void WriteError(ErrorType type, std::string_view error, unsigned int line = 0, const char* file = nullptr, const char* function = nullptr) override;
StdLogger& operator=(const StdLogger&) = default;
StdLogger& operator=(StdLogger&&) noexcept = default;

View File

@ -53,7 +53,7 @@ namespace Nz
bool SetCursorPos(UInt64 offset);
bool Write(const ByteArray& byteArray);
bool Write(const std::string_view& string);
bool Write(std::string_view string);
inline std::size_t Write(const void* buffer, std::size_t size);
Stream& operator=(const Stream&) = delete;

View File

@ -39,7 +39,7 @@ namespace Nz
* \param file Filename
* \param function Name of the function throwing the error
*/
void AbstractLogger::WriteError(ErrorType type, const std::string_view& error, unsigned int line, const char* file, const char* function)
void AbstractLogger::WriteError(ErrorType type, std::string_view error, unsigned int line, const char* file, const char* function)
{
NAZARA_USE_ANONYMOUS_NAMESPACE

View File

@ -91,7 +91,7 @@ namespace Nz
* \see WriteError
*/
void FileLogger::Write(const std::string_view& string)
void FileLogger::Write(std::string_view string)
{
if (m_forceStdOutput || m_stdReplicationEnabled)
{
@ -147,7 +147,7 @@ namespace Nz
* \see Write
*/
void FileLogger::WriteError(ErrorType type, const std::string_view& error, unsigned int line, const char* file, const char* function)
void FileLogger::WriteError(ErrorType type, std::string_view error, unsigned int line, const char* file, const char* function)
{
AbstractLogger::WriteError(type, error, line, file, function);
m_outputFile.flush();

View File

@ -78,7 +78,7 @@ namespace Nz
* \see WriteError
*/
void Log::Write(const std::string_view& string)
void Log::Write(std::string_view string)
{
if (s_enabled)
s_logger->Write(string);
@ -98,7 +98,7 @@ namespace Nz
* \see Write
*/
void Log::WriteError(ErrorType type, const std::string_view& error, unsigned int line, const char* file, const char* function)
void Log::WriteError(ErrorType type, std::string_view error, unsigned int line, const char* file, const char* function)
{
if (s_enabled)
s_logger->WriteError(type, error, line, file, function);

View File

@ -61,9 +61,9 @@ namespace Nz
* \see WriteError
*/
void StdLogger::Write(const std::string_view& error)
void StdLogger::Write(std::string_view string)
{
fwrite(error.data(), sizeof(char), error.size(), stdout);
fwrite(string.data(), sizeof(char), string.size(), stdout);
fputc('\n', stdout);
}
@ -79,7 +79,7 @@ namespace Nz
* \see Write
*/
void StdLogger::WriteError(ErrorType type, const std::string_view& error, unsigned int line, const char* file, const char* function)
void StdLogger::WriteError(ErrorType type, std::string_view error, unsigned int line, const char* file, const char* function)
{
NAZARA_USE_ANONYMOUS_NAMESPACE

View File

@ -257,7 +257,7 @@ namespace Nz
* \param string String to write
*/
bool Stream::Write(const std::string_view& string)
bool Stream::Write(std::string_view string)
{
if (m_streamOptions & StreamOption::Text)
{