mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
Time: Remove static from function local constexpr variable
Problem: - Function local `constexpr` variables do not need to be `static`. This consumes memory which is unnecessary and can prevent some optimizations. - C-style arrays are not as safe as AK::Arrays and require the user to specify the length of the array manually. Solution: - Remove `static` keyword. - Change from C-style array for AK::Array.
This commit is contained in:
parent
9cc201fb29
commit
0681086cad
Notes:
sideshowbarker
2024-07-18 22:57:59 +09:00
Author: https://github.com/ldm5180 Commit: https://github.com/SerenityOS/serenity/commit/0681086cad9 Pull-request: https://github.com/SerenityOS/serenity/pull/7266
1 changed files with 3 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/Checked.h>
|
||||
#include <AK/Time.h>
|
||||
|
||||
|
@ -21,7 +22,7 @@ int day_of_year(int year, unsigned month, int day)
|
|||
{
|
||||
VERIFY(month >= 1 && month <= 12);
|
||||
|
||||
static const int seek_table[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
|
||||
constexpr Array seek_table = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
|
||||
int day_of_year = seek_table[month - 1] + day - 1;
|
||||
|
||||
if (is_leap_year(year) && month >= 3)
|
||||
|
@ -43,7 +44,7 @@ int days_in_month(int year, unsigned month)
|
|||
unsigned day_of_week(int year, unsigned month, int day)
|
||||
{
|
||||
VERIFY(month >= 1 && month <= 12);
|
||||
static const int seek_table[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
|
||||
constexpr Array seek_table = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
|
||||
if (month < 3)
|
||||
--year;
|
||||
|
||||
|
|
Loading…
Reference in a new issue