Make 73 numeric constants const, moving them into .rdata (#234)

This change makes the 73 variables in ratconst.h actually
inline const, which allows them to move from the mutable .data
section of the executable, and into the read-only .rdata
section instead.

Moving data to the .rdata section has a number of benefits,
such as preventing possible corruption due to stray writes,
or other memory corruption.

Additionally, the initialization at run-time start-up is no
longer needed, so there is also a reduction in the .text
(code) section as well.

As a result the overall size of the Calculator.exe binary
(on x64 Release builds) decreases by 1,536 bytes (or ~1.5 KB)
with no change in behavior other than a small performance benefit.
This commit is contained in:
Jeff Genovy
2019-03-13 13:10:14 -07:00
committed by Daniel Belcher
parent 7663c0d5f2
commit 251578047f
4 changed files with 119 additions and 117 deletions

View File

@@ -411,7 +411,7 @@ extern void tanrat( _Inout_ PRAT *px, uint32_t radix, int32_t precision);
// angle type
extern void tananglerat( _Inout_ PRAT *px, ANGLE_TYPE angletype, uint32_t radix, int32_t precision);
extern void _dupnum(_In_ PNUMBER dest, _In_ PNUMBER src);
extern void _dupnum(_In_ PNUMBER dest, _In_ const NUMBER * const src);
extern void _destroynum( _In_ PNUMBER pnum );
extern void _destroyrat( _In_ PRAT prat );