LibCore: Change Core::DateTime::parse to accept a StringView
No reason to force an allocation here, as we do not require a NUL- terminated string.
This commit is contained in:
parent
6655de189f
commit
fd0075083a
Notes:
sideshowbarker
2024-07-17 17:38:29 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/fd0075083a Pull-request: https://github.com/SerenityOS/serenity/pull/21833
2 changed files with 2 additions and 2 deletions
Userland/Libraries/LibCore
|
@ -284,7 +284,7 @@ DeprecatedString DateTime::to_deprecated_string(StringView format) const
|
|||
return MUST(to_string(format)).to_deprecated_string();
|
||||
}
|
||||
|
||||
Optional<DateTime> DateTime::parse(StringView format, DeprecatedString const& string)
|
||||
Optional<DateTime> DateTime::parse(StringView format, StringView string)
|
||||
{
|
||||
unsigned format_pos = 0;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
static DateTime create(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0);
|
||||
static DateTime now();
|
||||
static DateTime from_timestamp(time_t);
|
||||
static Optional<DateTime> parse(StringView format, DeprecatedString const& string);
|
||||
static Optional<DateTime> parse(StringView format, StringView string);
|
||||
|
||||
bool operator<(DateTime const& other) const { return m_timestamp < other.m_timestamp; }
|
||||
bool operator==(DateTime const& other) const { return m_timestamp == other.m_timestamp; }
|
||||
|
|
Loading…
Add table
Reference in a new issue