comparison 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
comparison
equal deleted inserted replaced
11:da231533c5c7 12:424111a36ed7
119 for (const auto& c : input) 119 for (const auto& c : input)
120 { 120 {
121 result += key_press(c); 121 result += key_press(c);
122 } 122 }
123 return result; 123 return result;
124 }
125
126 // Process a buffer of pre-processed text of length n, placing the result in an output buffer.
127 void process_data(const char* input, char* output, std::size_t n)
128 {
129 for (std::size_t i = 0; i < n; ++i)
130 {
131 step_rotors();
132 *output++ = electric_signal(*input++) + 'A';
133 }
124 } 134 }
125 135
126 // for access to the plugboard for hill-climbing, etc 136 // for access to the plugboard for hill-climbing, etc
127 plugboard& get_plugboard() { return pb; } 137 plugboard& get_plugboard() { return pb; }
128 138