mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
Userland: Change static const variables to static constexpr
`static const` variables can be computed and initialized at run-time during initialization or the first time a function is called. Change them to `static constexpr` to ensure they are computed at compile-time. This allows some removal of `strlen` because the length of the `StringView` can be used which is pre-computed at compile-time.
This commit is contained in:
parent
31515a9147
commit
f912a48315
23 changed files with 111 additions and 82 deletions
|
@ -5,6 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
#include <LibGUI/Calendar.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
|
@ -16,21 +17,21 @@ REGISTER_WIDGET(GUI, Calendar);
|
|||
|
||||
namespace GUI {
|
||||
|
||||
static const char* long_day_names[] = {
|
||||
static constexpr Array<StringView, 7> long_day_names = {
|
||||
"Sunday", "Monday", "Tuesday", "Wednesday",
|
||||
"Thursday", "Friday", "Saturday"
|
||||
};
|
||||
|
||||
static const char* short_day_names[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
|
||||
static const char* mini_day_names[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" };
|
||||
static const char* micro_day_names[] = { "S", "M", "T", "W", "T", "F", "S" };
|
||||
static constexpr Array<StringView, 7> short_day_names = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
|
||||
static constexpr Array<StringView, 7> mini_day_names = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" };
|
||||
static constexpr Array<StringView, 7> micro_day_names = { "S", "M", "T", "W", "T", "F", "S" };
|
||||
|
||||
static const char* long_month_names[] = {
|
||||
static constexpr Array<StringView, 12> long_month_names = {
|
||||
"January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December"
|
||||
};
|
||||
|
||||
static const char* short_month_names[] = {
|
||||
static constexpr Array<StringView, 12> short_month_names = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue