luna: Make OwnedStringView::clone() just call from_string_literal()
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-01-10 19:03:00 +01:00
parent 3ac3d54788
commit 5aa667c776
Signed by: asleepymoon
GPG Key ID: B8A7D06E42258954

View File

@ -28,11 +28,7 @@ OwnedStringView::~OwnedStringView()
Result<OwnedStringView> OwnedStringView::clone() const
{
char* const c_str = strdup(m_string);
if (!c_str) return err(ENOMEM);
return OwnedStringView { c_str };
return from_string_literal(m_string);
}
const char& OwnedStringView::operator[](usize index) const
@ -43,7 +39,7 @@ const char& OwnedStringView::operator[](usize index) const
Result<OwnedStringView> OwnedStringView::from_string_literal(const char* str)
{
char* dup = strdup(str);
char* const dup = strdup(str);
if (!dup) return err(ENOMEM);
return OwnedStringView { dup };
}