-
Notifications
You must be signed in to change notification settings - Fork 172
On the go refactoring
As with all older code bases, Gridcoin could use some code polishing and adaptations to newer C++ standards. When doing the kind of refactorings where you replace one construct with another you have two options: you either change all the incorrect construct to the new one, or you change them while you're editing a function anyway. Changing all at once is nice for consistency but can produce large diffs and makes merging between branches more difficult. Changing only the code you are editing for another purpose anyway allows for a less radical transition to the new constructs.
This document is intended as a guide for things to change when doing other Gridcoin work.
In C++ the result of an operation is converted to double if either side is a double, so there is rarely a need to do any manual conversions.
Replace this
dPriority += (double)nValueIn * nConf;
with this
dPriority += nValueIn * nConf;
Additionally there are a lot of places where an integer is printed as a double. Replace this
printf("Tx Size for %s %f",tx.GetHash().GetHex().c_str(),(double)nTxSize);
with this
printf("Tx Size for %s %i", tx.GetHash().GetHex().c_str(), nTxSize);
Rationale: It increases readability.