From fd0075083a7afb8a632ef4d1a08d85406a2c9360 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 7 Nov 2023 11:47:23 -0500 Subject: [PATCH] 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. --- Userland/Libraries/LibCore/DateTime.cpp | 2 +- Userland/Libraries/LibCore/DateTime.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibCore/DateTime.cpp b/Userland/Libraries/LibCore/DateTime.cpp index 9554c3743b..6d5b62ba92 100644 --- a/Userland/Libraries/LibCore/DateTime.cpp +++ b/Userland/Libraries/LibCore/DateTime.cpp @@ -284,7 +284,7 @@ DeprecatedString DateTime::to_deprecated_string(StringView format) const return MUST(to_string(format)).to_deprecated_string(); } -Optional DateTime::parse(StringView format, DeprecatedString const& string) +Optional DateTime::parse(StringView format, StringView string) { unsigned format_pos = 0; diff --git a/Userland/Libraries/LibCore/DateTime.h b/Userland/Libraries/LibCore/DateTime.h index 0ace2eeca9..d15dc9f40c 100644 --- a/Userland/Libraries/LibCore/DateTime.h +++ b/Userland/Libraries/LibCore/DateTime.h @@ -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 parse(StringView format, DeprecatedString const& string); + static Optional 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; }