-
Notifications
You must be signed in to change notification settings - Fork 0
Dev Notes: 2017_05_08
Sometimes it's good to see what can be done to refactor code as it can lead to some surprises. It turns out that the simplifications from a few days ago made it quite obvious that some refactoring might be in order.
The first thing that was evident was that the handling of zero-digit values wasn't consistent with the approaches of 1 and n, or m, digit values, as zero digit versions were handled inside the c8::natural class and not the digit array code. Moving all of these to the digit array code allowed for a lot of code to be deleted.
The next problem was that the digit array code wasn't consistently handling digit array buffers as sometimes we'd need to copy source arrays to prevent problems with overwriting, but other times we wouldn't. Now the digit array layer is entirely responsible for this.
Finally, the constructor and stream output methods weren't using efficient digit array functions but, instead, using features of the c8::natural class that they were helping implement. Aside from being much slower, this sort of recursive behaviour is harder to reason about.