Skip to content

Commit

Permalink
api: reduce code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jan 26, 2025
1 parent ff8b05a commit e29ae07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 2 additions & 9 deletions api/builtin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,9 @@ namespace jule

// Common template for the append function variants.
template <typename Dest, typename Components>
Dest __append(Dest dest, const Components &components)
inline Dest __append(Dest dest, const Components &components)
{
if (components._len == 0)
return dest;
dest.alloc_for_append(components._len);
std::copy(
components._slice,
components._slice + components._len,
dest._slice + dest._len);
dest._len += components._len;
dest.append(components);
return dest;
}

Expand Down
2 changes: 2 additions & 0 deletions api/slice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ namespace jule
template <typename Items>
void append(const Items &items)
{
if (items._len == 0)
return;
this->alloc_for_append(items._len);
std::copy(items._slice, items._slice + items._len, this->_slice + this->_len);
this->_len += items._len;
Expand Down

0 comments on commit e29ae07

Please sign in to comment.