Mercurial > public > cpp-enigma
diff enigma/machine.h @ 12:424111a36ed7
Created enigma_machine::process_data() for some speed improvements.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 01 Jul 2012 12:53:10 -0500 |
parents | da231533c5c7 |
children | b9d124a15926 |
line wrap: on
line diff
--- a/enigma/machine.h Fri Jun 29 23:20:33 2012 -0500 +++ b/enigma/machine.h Sun Jul 01 12:53:10 2012 -0500 @@ -123,6 +123,16 @@ return result; } + // Process a buffer of pre-processed text of length n, placing the result in an output buffer. + void process_data(const char* input, char* output, std::size_t n) + { + for (std::size_t i = 0; i < n; ++i) + { + step_rotors(); + *output++ = electric_signal(*input++) + 'A'; + } + } + // for access to the plugboard for hill-climbing, etc plugboard& get_plugboard() { return pb; }