Skip to content

Commit

Permalink
Removed obsolete code after #3920
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-milovidov committed Mar 10, 2019
1 parent edb72e0 commit d95cd4a
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions dbms/src/Columns/ColumnString.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,36 +121,22 @@ class ColumnString final : public COWPtrHelper<IColumn, ColumnString>
void insertFrom(const IColumn & src_, size_t n) override
{
const ColumnString & src = static_cast<const ColumnString &>(src_);
const size_t size_to_append = src.offsets[n] - src.offsets[n - 1]; /// -1th index is Ok, see PaddedPODArray.

if (n != 0)
if (size_to_append == 1)
{
const size_t size_to_append = src.offsets[n] - src.offsets[n - 1];

if (size_to_append == 1)
{
/// shortcut for empty string
chars.push_back(0);
offsets.push_back(chars.size());
}
else
{
const size_t old_size = chars.size();
const size_t offset = src.offsets[n - 1];
const size_t new_size = old_size + size_to_append;

chars.resize(new_size);
memcpySmallAllowReadWriteOverflow15(chars.data() + old_size, &src.chars[offset], size_to_append);
offsets.push_back(new_size);
}
/// shortcut for empty string
chars.push_back(0);
offsets.push_back(chars.size());
}
else
{
const size_t old_size = chars.size();
const size_t size_to_append = src.offsets[0];
const size_t offset = src.offsets[n - 1];
const size_t new_size = old_size + size_to_append;

chars.resize(new_size);
memcpySmallAllowReadWriteOverflow15(chars.data() + old_size, &src.chars[0], size_to_append);
memcpySmallAllowReadWriteOverflow15(chars.data() + old_size, &src.chars[offset], size_to_append);
offsets.push_back(new_size);
}
}
Expand Down

0 comments on commit d95cd4a

Please sign in to comment.