luna: Make OwnedStringView::clone() just call from_string_literal()
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3ac3d54788
commit
5aa667c776
@ -28,11 +28,7 @@ OwnedStringView::~OwnedStringView()
|
|||||||
|
|
||||||
Result<OwnedStringView> OwnedStringView::clone() const
|
Result<OwnedStringView> OwnedStringView::clone() const
|
||||||
{
|
{
|
||||||
char* const c_str = strdup(m_string);
|
return from_string_literal(m_string);
|
||||||
|
|
||||||
if (!c_str) return err(ENOMEM);
|
|
||||||
|
|
||||||
return OwnedStringView { c_str };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char& OwnedStringView::operator[](usize index) const
|
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)
|
Result<OwnedStringView> OwnedStringView::from_string_literal(const char* str)
|
||||||
{
|
{
|
||||||
char* dup = strdup(str);
|
char* const dup = strdup(str);
|
||||||
if (!dup) return err(ENOMEM);
|
if (!dup) return err(ENOMEM);
|
||||||
return OwnedStringView { dup };
|
return OwnedStringView { dup };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user