Addition to prev. revision [#METR-2944].

This commit is contained in:
Alexey Milovidov 2016-12-30 03:19:05 +03:00
parent b4e18e2222
commit 6e1ec28840

View File

@ -16,6 +16,24 @@ namespace DB
{ {
static inline UInt64 stringWidth(const UInt8 * pos, const UInt8 * end)
{
UInt64 res = 0;
for (; pos < end; ++pos)
{
if (*pos == '\b' || *pos == '\f' || *pos == '\n' || *pos == '\r' || *pos == '\t' || *pos == '\0' || *pos == '\'' || *pos == '\\')
++res;
if (*pos <= 0x7F || *pos >= 0xC0)
++res;
}
return res;
}
static inline UInt64 stringWidthConstant(const String & data)
{
return stringWidth(reinterpret_cast<const UInt8 *>(data.data()), reinterpret_cast<const UInt8 *>(data.data()) + data.size());
}
template <typename T> template <typename T>
static void numWidthVector(const PaddedPODArray<T> & a, PaddedPODArray<UInt64> & c) static void numWidthVector(const PaddedPODArray<T> & a, PaddedPODArray<UInt64> & c)
{ {