#include "tile/base/slice.h"
#include "tile/base/internal/logging.h"

namespace tile {
std::size_t
Slice::find(Slice s, std::size_t pos) const
{
    TILE_CHECK(pos <= len_);

    if (s.empty()) { return npos; }

    auto iter = std::search(data_ + pos, data_ + len_, s.data(), s.data() + s.size());
    return iter == data_ + len_ ? npos : iter - data_;
}

}// namespace tile
