From 08804f22b8f5759b119114845048f4f1c5eb7f5d Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Wed, 12 Oct 2022 19:58:24 +0300 Subject: [PATCH] Improve COutputStream::WriteChar Former-commit-id: ef751ff69f7091b6fccc4bf57ce186b2b48b5fc4 --- include/Kyoto/Streams/COutputStream.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/Kyoto/Streams/COutputStream.hpp b/include/Kyoto/Streams/COutputStream.hpp index 3583326a..6d907015 100644 --- a/include/Kyoto/Streams/COutputStream.hpp +++ b/include/Kyoto/Streams/COutputStream.hpp @@ -40,12 +40,11 @@ public: void WriteChar(u8 c) { FlushShiftRegister(); - if (mBufLen <= mUnwrittenLen) { + if (mUnwrittenLen >= mBufLen) { DoFlush(); } ++mNumWrites; - *(reinterpret_cast< u8* >(mBufPtr) + mUnwrittenLen) = c; - ++mUnwrittenLen; + *(reinterpret_cast< u8* >(mBufPtr) + mUnwrittenLen++) = c; } @@ -82,7 +81,7 @@ inline void coutput_stream_helper(const uint& t, COutputStream& out) { template <> inline void coutput_stream_helper(const bool& t, COutputStream& out) { - out.WriteChar(static_cast< char >(t)); + out.WriteChar(static_cast< u8 >(t)); } #endif // _COUTPUTSTREAM