Slightly better

This commit is contained in:
Alexey Milovidov 2021-01-04 21:07:52 +03:00
parent 5e75bad82a
commit 12a0ef907e
2 changed files with 3 additions and 3 deletions

View File

@ -730,7 +730,7 @@ static const char digits100[201] =
template <char delimiter = '-'>
inline void writeDateText(const LocalDate & date, WriteBuffer & buf)
{
if (buf.position() && buf.position() + 10 <= buf.buffer().end())
if (reinterpret_cast<intptr_t>(buf.position()) + 10 <= reinterpret_cast<intptr_t>(buf.buffer().end()))
{
memcpy(buf.position(), &digits100[date.year() / 100 * 2], 2);
buf.position() += 2;
@ -767,7 +767,7 @@ inline void writeDateText(DayNum date, WriteBuffer & buf)
template <char date_delimeter = '-', char time_delimeter = ':', char between_date_time_delimiter = ' '>
inline void writeDateTimeText(const LocalDateTime & datetime, WriteBuffer & buf)
{
if (buf.position() && buf.position() + 19 <= buf.buffer().end())
if (reinterpret_cast<intptr_t>(buf.position()) + 19 <= reinterpret_cast<intptr_t>(buf.buffer().end()))
{
memcpy(buf.position(), &digits100[datetime.year() / 100 * 2], 2);
buf.position() += 2;

View File

@ -24,7 +24,7 @@ namespace detail
template <typename T>
void writeIntText(T x, WriteBuffer & buf)
{
if (likely(buf.position() && buf.position() + WRITE_HELPERS_MAX_INT_WIDTH < buf.buffer().end()))
if (likely(reinterpret_cast<intptr_t>(buf.position()) + WRITE_HELPERS_MAX_INT_WIDTH < reinterpret_cast<intptr_t>(buf.buffer().end())))
buf.position() = itoa(x, buf.position());
else
detail::writeUIntTextFallback(x, buf);