diff --git a/source/app.cpp b/source/app.cpp index 5cd51a1..56352e6 100644 --- a/source/app.cpp +++ b/source/app.cpp @@ -88,7 +88,7 @@ export namespace app { if (path_remaining.length < file_path.byte_size()) return nullptr; - coral::copy(path_remaining, coral::slice{file_path.begin(), file_path.end()}.as_bytes()); + coral::copy(path_remaining, file_path.as_slice().as_bytes()); return ::SDL_RWFromFile(reinterpret_cast(this->path_buffer), "r"); } diff --git a/source/coral/files.cpp b/source/coral/files.cpp index d583267..2231794 100644 --- a/source/coral/files.cpp +++ b/source/coral/files.cpp @@ -29,6 +29,13 @@ export namespace coral { this->buffer[max] = max - text_size; } + /** + * Returns a weak reference to the [path] as a [slice]. + */ + constexpr slice as_slice() const { + return {this->buffer, this->byte_size()}; + } + /** * Returns the base pointer of the path name. * @@ -50,8 +57,7 @@ export namespace coral { * they are identical. */ constexpr size compare(path const & that) const { - return coral::compare(slice{this->begin(), this->end()}.as_bytes(), - slice{that.begin(), that.end()}.as_bytes()); + return coral::compare(this->as_slice().as_bytes(), that.as_slice().as_bytes()); } /** @@ -66,8 +72,7 @@ export namespace coral { * otherwise `false`. */ constexpr bool equals(path const & that) const { - return coral::equals(slice{this->begin(), this->end()}.as_bytes(), - slice{that.begin(), that.end()}.as_bytes()); + return coral::equals(this->as_slice().as_bytes(), that.as_slice().as_bytes()); } /** @@ -76,7 +81,7 @@ export namespace coral { * *Note:* the returned hash code is not guaranteed to be unique. */ constexpr u64 hash() const { - return coral::hash(slice{this->begin(), this->end()}.as_bytes()); + return coral::hash(this->as_slice().as_bytes()); } /**