From 96be295fb64bd17fe6a3b5f81c8d09d628366386 Mon Sep 17 00:00:00 2001 From: MHotchin Date: Wed, 18 Dec 2019 18:27:41 -0800 Subject: [PATCH 1/3] Allow inline declaration of TimeChangeRule. Saves 24 bytes RAM. --- src/Timezone.cpp | 8 ++++++++ src/Timezone.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/Timezone.cpp b/src/Timezone.cpp index fbf4fdf..32662d8 100644 --- a/src/Timezone.cpp +++ b/src/Timezone.cpp @@ -12,6 +12,14 @@ #include #endif + +TimeChangeRule::TimeChangeRule(const char *a, uint8_t w, uint8_t d, + uint8_t m, uint8_t h, int o) + : week(w), dow(d), month(m), hour(h), offset(o) +{ + strncpy(abbrev, a, sizeof(abbrev)); +} + /*----------------------------------------------------------------------* * Create a Timezone object from the given time change rules. * *----------------------------------------------------------------------*/ diff --git a/src/Timezone.h b/src/Timezone.h index 8d353ec..1ad6206 100644 --- a/src/Timezone.h +++ b/src/Timezone.h @@ -30,8 +30,13 @@ struct TimeChangeRule uint8_t month; // 1=Jan, 2=Feb, ... 12=Dec uint8_t hour; // 0-23 int offset; // offset from UTC in minutes + + TimeChangeRule() = default; + TimeChangeRule(const char *, uint8_t week, uint8_t dow, uint8_t month, uint8_t hour, int offset); }; + + class Timezone { public: From a6fcfa864fa08593faca998e7417679939b6f3c8 Mon Sep 17 00:00:00 2001 From: MHotchin Date: Wed, 18 Dec 2019 18:28:40 -0800 Subject: [PATCH 2/3] Revert "Allow inline declaration of TimeChangeRule. Saves 24 bytes RAM." This reverts commit 96be295fb64bd17fe6a3b5f81c8d09d628366386. --- src/Timezone.cpp | 8 -------- src/Timezone.h | 5 ----- 2 files changed, 13 deletions(-) diff --git a/src/Timezone.cpp b/src/Timezone.cpp index 32662d8..fbf4fdf 100644 --- a/src/Timezone.cpp +++ b/src/Timezone.cpp @@ -12,14 +12,6 @@ #include #endif - -TimeChangeRule::TimeChangeRule(const char *a, uint8_t w, uint8_t d, - uint8_t m, uint8_t h, int o) - : week(w), dow(d), month(m), hour(h), offset(o) -{ - strncpy(abbrev, a, sizeof(abbrev)); -} - /*----------------------------------------------------------------------* * Create a Timezone object from the given time change rules. * *----------------------------------------------------------------------*/ diff --git a/src/Timezone.h b/src/Timezone.h index 1ad6206..8d353ec 100644 --- a/src/Timezone.h +++ b/src/Timezone.h @@ -30,13 +30,8 @@ struct TimeChangeRule uint8_t month; // 1=Jan, 2=Feb, ... 12=Dec uint8_t hour; // 0-23 int offset; // offset from UTC in minutes - - TimeChangeRule() = default; - TimeChangeRule(const char *, uint8_t week, uint8_t dow, uint8_t month, uint8_t hour, int offset); }; - - class Timezone { public: From 1272772407216c46722a414b0c2aeeec72991623 Mon Sep 17 00:00:00 2001 From: MHotchin Date: Wed, 18 Dec 2019 18:39:14 -0800 Subject: [PATCH 3/3] Allow inline declaration of TimeChangeRule. Saves 24 bytes. --- src/Timezone.cpp | 7 +++++++ src/Timezone.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/Timezone.cpp b/src/Timezone.cpp index fbf4fdf..110ab72 100644 --- a/src/Timezone.cpp +++ b/src/Timezone.cpp @@ -12,6 +12,13 @@ #include #endif +TimeChangeRule::TimeChangeRule(const char *a, uint8_t w, uint8_t d, + uint8_t m, uint8_t h, int o) + : week(w), dow(d), month(m), hour(h), offset(o) +{ + strncpy(abbrev, a, sizeof(abbrev)); +} + /*----------------------------------------------------------------------* * Create a Timezone object from the given time change rules. * *----------------------------------------------------------------------*/ diff --git a/src/Timezone.h b/src/Timezone.h index 8d353ec..9e18f8f 100644 --- a/src/Timezone.h +++ b/src/Timezone.h @@ -30,6 +30,10 @@ struct TimeChangeRule uint8_t month; // 1=Jan, 2=Feb, ... 12=Dec uint8_t hour; // 0-23 int offset; // offset from UTC in minutes + + TimeChangeRule() = default; + TimeChangeRule(const char *abbrev, uint8_t week, uint8_t dow, + uint8_t month, uint8_t hour, int offset); }; class Timezone