@@ -35,58 +35,58 @@ namespace OpenVic {
3535 day_t days;
3636
3737 public:
38- constexpr Timespan (day_t value = 0 ) : days { value } {}
38+ OV_ALWAYS_INLINE constexpr Timespan (day_t value = 0 ) : days { value } {}
3939
40- friend constexpr auto operator <=>(Timespan const &, Timespan const &) = default ;
41- friend constexpr bool operator ==(Timespan const &, Timespan const &) = default ;
42- constexpr Timespan operator +(Timespan other) const {
40+ OV_ALWAYS_INLINE friend constexpr auto operator <=>(Timespan const &, Timespan const &) = default ;
41+ OV_ALWAYS_INLINE friend constexpr bool operator ==(Timespan const &, Timespan const &) = default ;
42+ OV_SPEED_INLINE constexpr Timespan operator +(Timespan other) const {
4343 return days + other.days ;
4444 }
45- constexpr Timespan operator -(Timespan other) const {
45+ OV_SPEED_INLINE constexpr Timespan operator -(Timespan other) const {
4646 return days - other.days ;
4747 }
48- constexpr Timespan operator *(day_t factor) const {
48+ OV_SPEED_INLINE constexpr Timespan operator *(day_t factor) const {
4949 return days * factor;
5050 }
51- constexpr Timespan operator /(day_t factor) const {
51+ OV_SPEED_INLINE constexpr Timespan operator /(day_t factor) const {
5252 return days / factor;
5353 }
54- constexpr Timespan& operator +=(Timespan other) {
54+ OV_SPEED_INLINE constexpr Timespan& operator +=(Timespan other) {
5555 days += other.days ;
5656 return *this ;
5757 }
58- constexpr Timespan& operator -=(Timespan other) {
58+ OV_SPEED_INLINE constexpr Timespan& operator -=(Timespan other) {
5959 days -= other.days ;
6060 return *this ;
6161 }
62- constexpr Timespan& operator ++() {
62+ OV_SPEED_INLINE constexpr Timespan& operator ++() {
6363 days++;
6464 return *this ;
6565 }
66- constexpr Timespan operator ++(int ) {
66+ OV_SPEED_INLINE constexpr Timespan operator ++(int ) {
6767 Timespan old = *this ;
6868 ++(*this );
6969 return old;
7070 }
71- constexpr Timespan& operator --() {
71+ OV_SPEED_INLINE constexpr Timespan& operator --() {
7272 days--;
7373 return *this ;
7474 }
75- constexpr Timespan operator --(int ) {
75+ OV_SPEED_INLINE constexpr Timespan operator --(int ) {
7676 Timespan old = *this ;
7777 --(*this );
7878 return old;
7979 }
80- constexpr Timespan operator -() const {
80+ OV_SPEED_INLINE constexpr Timespan operator -() const {
8181 Timespan ret = *this ;
8282 ret.days = -ret.days ;
8383 return ret;
8484 }
8585
86- constexpr day_t to_int () const {
86+ OV_ALWAYS_INLINE constexpr day_t to_int () const {
8787 return days;
8888 }
89- explicit constexpr operator day_t () const {
89+ OV_ALWAYS_INLINE explicit constexpr operator day_t () const {
9090 return days;
9191 }
9292
@@ -97,9 +97,9 @@ namespace OpenVic {
9797 memory::string to_string () const ;
9898 explicit operator memory::string () const ;
9999
100- static constexpr Timespan from_years (day_t num);
101- static constexpr Timespan from_months (day_t num);
102- static constexpr Timespan from_days (day_t num);
100+ OV_SPEED_INLINE static constexpr Timespan from_years (day_t num);
101+ OV_SPEED_INLINE static constexpr Timespan from_months (day_t num);
102+ OV_SPEED_INLINE static constexpr Timespan from_days (day_t num);
103103 };
104104 std::ostream& operator <<(std::ostream& out, Timespan const & timespan);
105105
@@ -166,7 +166,7 @@ namespace OpenVic {
166166 // Number of days since Jan 1st, Year 0
167167 Timespan PROPERTY (timespan);
168168
169- static constexpr Timespan _date_to_timespan (year_t year, month_t month, day_t day) {
169+ OV_SPEED_INLINE static constexpr Timespan _date_to_timespan (year_t year, month_t month, day_t day) {
170170 month = std::clamp<month_t >(month, 1 , MONTHS_IN_YEAR);
171171 day = std::clamp<day_t >(day, 1 , DAYS_IN_MONTH[month - 1 ]);
172172 return year * DAYS_IN_YEAR + DAYS_UP_TO_MONTH[month - 1 ] + day - 1 ;
@@ -175,89 +175,89 @@ namespace OpenVic {
175175 public:
176176 // The Timespan is considered to be the number of days since Jan 1st, Year 0.
177177 // Negative Timespans indicate dates before Jan 1st, Year 0.
178- constexpr Date (Timespan new_timespan) : timespan { new_timespan } {}
178+ OV_ALWAYS_INLINE constexpr Date (Timespan new_timespan) : timespan { new_timespan } {}
179179 // Year month day specification
180- constexpr Date (year_t year = 0 , month_t month = 1 , day_t day = 1 ) : timespan { _date_to_timespan (year, month, day) } {}
180+ OV_ALWAYS_INLINE constexpr Date (year_t year = 0 , month_t month = 1 , day_t day = 1 ) : timespan { _date_to_timespan (year, month, day) } {}
181181
182- constexpr Timespan::day_t get_day_of_year () const {
182+ OV_SPEED_INLINE constexpr Timespan::day_t get_day_of_year () const {
183183 Timespan::day_t day_in_year = static_cast <Timespan::day_t >(timespan) % DAYS_IN_YEAR;
184184 if (day_in_year < 0 ) {
185185 day_in_year += DAYS_IN_YEAR;
186186 }
187187 return day_in_year;
188188 }
189189
190- constexpr year_t get_year () const {
190+ OV_SPEED_INLINE constexpr year_t get_year () const {
191191 return (timespan >= 0
192192 ? static_cast <Timespan::day_t >(timespan)
193193 : static_cast <Timespan::day_t >(timespan) - DAYS_IN_YEAR + 1
194194 ) / DAYS_IN_YEAR;
195195 }
196- constexpr month_t get_month () const {
196+ OV_SPEED_INLINE constexpr month_t get_month () const {
197197 return MONTH_FROM_DAY_IN_YEAR[get_day_of_year ()];
198198 }
199- constexpr day_t get_day () const {
199+ OV_SPEED_INLINE constexpr day_t get_day () const {
200200 Timespan::day_t day_of_year = get_day_of_year ();
201201 return day_of_year - DAYS_UP_TO_MONTH[MONTH_FROM_DAY_IN_YEAR[day_of_year] - 1 ] + 1 ;
202202 }
203203
204204 // Due to the lack of leap years, this will not fit historical weekdays
205- constexpr day_t get_day_of_week () const {
205+ OV_SPEED_INLINE constexpr day_t get_day_of_week () const {
206206 return (static_cast <Timespan::day_t >(timespan) + INITIAL_WEEKDAY_NAME) % WEEKDAY_NAMES.size ();
207207 }
208208
209- constexpr day_t get_week_of_year () const {
209+ OV_SPEED_INLINE constexpr day_t get_week_of_year () const {
210210 return (get_day_of_year () + WEEKDAY_NAMES.size () - get_day_of_week ()) / WEEKDAY_NAMES.size ();
211211 }
212212
213- constexpr bool is_month_start () const {
213+ OV_SPEED_INLINE constexpr bool is_month_start () const {
214214 return get_day () == 1 ;
215215 }
216216
217- friend constexpr auto operator <=>(Date const &, Date const &) = default ;
218- friend constexpr bool operator ==(Date const &, Date const &) = default ;
219- constexpr Date operator +(Timespan other) const {
217+ OV_ALWAYS_INLINE friend constexpr auto operator <=>(Date const &, Date const &) = default ;
218+ OV_ALWAYS_INLINE friend constexpr bool operator ==(Date const &, Date const &) = default ;
219+ OV_SPEED_INLINE constexpr Date operator +(Timespan other) const {
220220 return timespan + other;
221221 }
222- constexpr Date operator -(Timespan other) const {
222+ OV_SPEED_INLINE constexpr Date operator -(Timespan other) const {
223223 return timespan - other;
224224 }
225- constexpr Timespan operator -(Date other) const {
225+ OV_SPEED_INLINE constexpr Timespan operator -(Date other) const {
226226 return timespan - other.timespan ;
227227 }
228- constexpr Date& operator +=(Timespan other) {
228+ OV_SPEED_INLINE constexpr Date& operator +=(Timespan other) {
229229 timespan += other;
230230 return *this ;
231231 }
232- constexpr Date& operator -=(Timespan other) {
232+ OV_SPEED_INLINE constexpr Date& operator -=(Timespan other) {
233233 timespan -= other;
234234 return *this ;
235235 }
236- constexpr Date& operator ++() {
236+ OV_SPEED_INLINE constexpr Date& operator ++() {
237237 timespan++;
238238 return *this ;
239239 }
240- constexpr Date operator ++(int ) {
240+ OV_SPEED_INLINE constexpr Date operator ++(int ) {
241241 Date old = *this ;
242242 ++(*this );
243243 return old;
244244 }
245- constexpr Date& operator --() {
245+ OV_SPEED_INLINE constexpr Date& operator --() {
246246 timespan--;
247247 return *this ;
248248 }
249- constexpr Date operator --(int ) {
249+ OV_SPEED_INLINE constexpr Date operator --(int ) {
250250 Date old = *this ;
251251 --(*this );
252252 return old;
253253 }
254254
255- constexpr bool in_range (Date start, Date end) const {
255+ OV_SPEED_INLINE constexpr bool in_range (Date start, Date end) const {
256256 assert (start <= end);
257257 return start <= *this && *this <= end;
258258 }
259259
260- constexpr std::string_view get_month_name () const {
260+ OV_SPEED_INLINE constexpr std::string_view get_month_name () const {
261261 const month_t month = get_month ();
262262 if (1 <= month && month <= MONTHS_IN_YEAR) {
263263 return MONTH_NAMES[month - 1 ];
@@ -266,11 +266,11 @@ namespace OpenVic {
266266 }
267267
268268 // Due to the lack of leap years, this will not fit historical weekdays
269- constexpr std::string_view get_weekday_name () const {
269+ OV_SPEED_INLINE constexpr std::string_view get_weekday_name () const {
270270 return WEEKDAY_NAMES[get_day_of_week ()];
271271 }
272272
273- inline constexpr std::to_chars_result to_chars ( //
273+ OV_SPEED_INLINE constexpr std::to_chars_result to_chars ( //
274274 char * first, char * last, bool pad_year = false , bool pad_month = true , bool pad_day = true
275275 ) const {
276276 year_t year = get_year ();
@@ -344,15 +344,15 @@ namespace OpenVic {
344344 }
345345
346346 struct stack_string ;
347- inline constexpr stack_string to_array (bool pad_year = false , bool pad_month = true , bool pad_day = true ) const ;
347+ OV_SPEED_INLINE constexpr stack_string to_array (bool pad_year = false , bool pad_month = true , bool pad_day = true ) const ;
348348
349349 struct stack_string final : StackString<
350350 fmt::detail::count_digits (uint64_t (std::numeric_limits<year_t >::max())) +
351351 fmt::detail::count_digits(uint64_t (MONTHS_IN_YEAR)) +
352352 fmt::detail::count_digits(uint64_t (MAX_DAYS_IN_MONTH)) + 4> {
353353 protected:
354354 using StackString::StackString;
355- friend inline constexpr stack_string Date::to_array (bool pad_year, bool pad_month, bool pad_day) const ;
355+ friend OV_SPEED_INLINE constexpr stack_string Date::to_array (bool pad_year, bool pad_month, bool pad_day) const ;
356356 };
357357
358358 memory::string to_string (bool pad_year = false , bool pad_month = true , bool pad_day = true ) const ;
@@ -392,7 +392,7 @@ namespace OpenVic {
392392 If day == 0, ec == not_supported and ptr == day's first, only year and month are changed
393393 If day > days in month, ec == value_too_large and ptr == month's first, only year month are changed
394394 */
395- inline static constexpr from_chars_result parse_from_chars ( //
395+ OV_SPEED_INLINE static constexpr from_chars_result parse_from_chars ( //
396396 const char * first, const char * last, year_t & year, month_t & month, day_t & day
397397 ) {
398398 int32_t year_check = year;
@@ -485,7 +485,7 @@ namespace OpenVic {
485485
486486 public:
487487 // Parsed from string of the form YYYY.MM.DD
488- constexpr from_chars_result from_chars (const char * first, const char * last) {
488+ OV_SPEED_INLINE constexpr from_chars_result from_chars (const char * first, const char * last) {
489489 year_t year = 0 ;
490490 month_t month = 0 ;
491491 day_t day = 0 ;
@@ -495,7 +495,7 @@ namespace OpenVic {
495495 }
496496
497497 // Parsed from string of the form YYYY.MM.DD
498- static constexpr Date from_string (std::string_view str, from_chars_result* from_chars = nullptr ) {
498+ OV_SPEED_INLINE static constexpr Date from_string (std::string_view str, from_chars_result* from_chars = nullptr ) {
499499 Date date {};
500500 if (from_chars == nullptr ) {
501501 date.from_chars (str.data (), str.data () + str.size ());
@@ -506,7 +506,7 @@ namespace OpenVic {
506506 }
507507
508508 private:
509- inline static Date handle_from_string_log (std::string_view str, from_chars_result* from_chars) {
509+ OV_SPEED_INLINE static Date handle_from_string_log (std::string_view str, from_chars_result* from_chars) {
510510 OV_ERR_FAIL_COND_V (from_chars == nullptr , Date {});
511511
512512 Date date = from_string (str, from_chars);
@@ -571,14 +571,14 @@ namespace OpenVic {
571571
572572 public:
573573 // Parsed from string of the form YYYY.MM.DD
574- static Date from_string_log (std::string_view str) {
574+ OV_SPEED_INLINE static Date from_string_log (std::string_view str) {
575575 from_chars_result from_chars {};
576576 Date date = handle_from_string_log (str, &from_chars);
577577 return date;
578578 }
579579
580580 // Parsed from string of the form YYYY.MM.DD
581- static Date from_string_log (std::string_view str, from_chars_result* from_chars) {
581+ OV_SPEED_INLINE static Date from_string_log (std::string_view str, from_chars_result* from_chars) {
582582 if (from_chars == nullptr ) {
583583 return from_string_log (str);
584584 }
@@ -588,17 +588,17 @@ namespace OpenVic {
588588 };
589589 std::ostream& operator <<(std::ostream& out, Date date);
590590
591- constexpr Timespan Timespan::from_years (day_t num) {
591+ OV_SPEED_INLINE constexpr Timespan Timespan::from_years (day_t num) {
592592 return num * Date::DAYS_IN_YEAR;
593593 }
594- constexpr Timespan Timespan::from_months (day_t num) {
594+ OV_SPEED_INLINE constexpr Timespan Timespan::from_months (day_t num) {
595595 return (num / Date::MONTHS_IN_YEAR) * Date::DAYS_IN_YEAR + Date::DAYS_UP_TO_MONTH[num % Date::MONTHS_IN_YEAR];
596596 }
597- constexpr Timespan Timespan::from_days (day_t num) {
597+ OV_SPEED_INLINE constexpr Timespan Timespan::from_days (day_t num) {
598598 return num;
599599 }
600600
601- inline constexpr Date::stack_string Date::to_array (bool pad_year, bool pad_month, bool pad_day) const {
601+ OV_SPEED_INLINE constexpr Date::stack_string Date::to_array (bool pad_year, bool pad_month, bool pad_day) const {
602602 stack_string str {};
603603 std::to_chars_result result =
604604 to_chars (str._array .data (), str._array .data () + str._array .size (), pad_year, pad_month, pad_day);
0 commit comments