|
EnigmaMachineCore 0.1.0
A modular Enigma Machine simulation in C++20
|
Accepted
The historical Enigma Machine's signal path flows forward through rotors, hits a reflector, and returns in reverse. Initially, the system used a single transform(position, reverse) virtual method. Every character transformation required checking the reverse flag, introducing a "branch" in the CPU's execution pipeline millions of times per message.
We will use Dedicated Forward and Reverse Signal Paths by splitting the transformation into transformForward(position) and transformReverse(position) methods.
if (reverse)) inside the tightest loop of the engine, improving CPU instruction pipelining and branch prediction.RotorBox::keyTransform) becomes more readable and explicit about which direction the signal is traveling.transformReverse path, making the implementation more faithful to the physical hardware.Transformer by adding two more virtual functions.transformForward and transformReverse (coordinate shifts), but the performance gain in the hot path outweighs the maintenance cost.