Skip to content

Commit c252b87

Browse files
committed
README.md: add comment about why FCString should NOT inherit from Printable
1 parent 8a9cd89 commit c252b87

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/aunit/FCString.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ namespace aunit {
3838
* outside a function, it can only be used inside a function, so we are forced
3939
* to use normal c-strings instead of F() strings when manually creating Test or
4040
* TestOnce instances.
41+
*
42+
* I deliberately decided not to inherit from Printable. While it is convenient
43+
* to be able to call Print::print() with an instance of this class, the cost
44+
* is 2 (AVR) or 4 (Teensy-ARM or ESP8266) extra bytes of static memory for the
45+
* v-table pointer for each instance. But each instance is only 3 (AVR) or 5
46+
* (Teensy-ARM or ESP8266) bytes big, so the cost of 50-100 bytes of static
47+
* memory for a large suite of 25 unit tests does not seem worth the minor
48+
* convenience.
4149
*/
4250
class FCString {
4351
public:

0 commit comments

Comments
 (0)