Merge pull request #53893 from ClibMouse/feature/make-it-old-school

Use iterators instead of std::ranges
This commit is contained in:
Robert Schulze 2023-08-31 14:55:45 +02:00 committed by GitHub
commit 77327c69ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 15 deletions

View File

@ -34,10 +34,8 @@ void SerializationDecimalBase<T>::serializeBinaryBulk(const IColumn & column, Wr
limit = size - offset;
if constexpr (std::endian::native == std::endian::big)
{
std::ranges::for_each(
x | std::views::drop(offset) | std::views::take(limit), [&ostr](const auto & d) { writeBinaryLittleEndian(d, ostr); });
}
for (size_t i = offset; i < offset + limit; ++i)
writeBinaryLittleEndian(x[i], ostr);
else
ostr.write(reinterpret_cast<const char *>(&x[offset]), sizeof(FieldType) * limit);
}
@ -68,8 +66,8 @@ void SerializationDecimalBase<T>::deserializeBinaryBulk(IColumn & column, ReadBu
x.resize(initial_size + size / sizeof(FieldType));
if constexpr (std::endian::native == std::endian::big)
std::ranges::for_each(
x | std::views::drop(initial_size), [](auto & d) { transformEndianness<std::endian::big, std::endian::little>(d); });
for (size_t i = initial_size; i < x.size(); ++i)
transformEndianness<std::endian::big, std::endian::little>(x[i]);
}
template class SerializationDecimalBase<Decimal32>;

View File

@ -144,10 +144,8 @@ void SerializationNumber<T>::serializeBinaryBulk(const IColumn & column, WriteBu
return;
if constexpr (std::endian::native == std::endian::big && sizeof(T) >= 2)
{
std::ranges::for_each(
x | std::views::drop(offset) | std::views::take(limit), [&ostr](const auto & i) { writeBinaryLittleEndian(i, ostr); });
}
for (size_t i = offset; i < offset + limit; ++i)
writeBinaryLittleEndian(x[i], ostr);
else
ostr.write(reinterpret_cast<const char *>(&x[offset]), sizeof(typename ColumnVector<T>::ValueType) * limit);
}
@ -162,7 +160,8 @@ void SerializationNumber<T>::deserializeBinaryBulk(IColumn & column, ReadBuffer
x.resize(initial_size + size / sizeof(typename ColumnVector<T>::ValueType));
if constexpr (std::endian::native == std::endian::big && sizeof(T) >= 2)
std::ranges::for_each(x | std::views::drop(initial_size), [](auto & i) { transformEndianness<std::endian::big, std::endian::little>(i); });
for (size_t i = initial_size; i < x.size(); ++i)
transformEndianness<std::endian::big, std::endian::little>(x[i]);
}
template class SerializationNumber<UInt8>;

View File

@ -147,8 +147,8 @@ void SerializationUUID::serializeBinaryBulk(const IColumn & column, WriteBuffer
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code"
std::ranges::for_each(
x | std::views::drop(offset) | std::views::take(limit), [&ostr](const auto & uuid) { writeBinaryLittleEndian(uuid, ostr); });
for (size_t i = offset; i < offset + limit; ++i)
writeBinaryLittleEndian(x[i], ostr);
#pragma clang diagnostic pop
}
else
@ -166,8 +166,8 @@ void SerializationUUID::deserializeBinaryBulk(IColumn & column, ReadBuffer & ist
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code"
if constexpr (std::endian::native == std::endian::big)
std::ranges::for_each(
x | std::views::drop(initial_size), [](auto & uuid) { transformEndianness<std::endian::big, std::endian::little>(uuid); });
for (size_t i = initial_size; i < x.size(); ++i)
transformEndianness<std::endian::big, std::endian::little>(x[i]);
#pragma clang diagnostic pop
}
}