-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed
Labels
Milestone
Description
Please consider adding big.Int methods Inc and Dec which would increase or decrease the given Int by one. It would be similar to the following code, except for the allocation:
x.Add(x, big.NewInt(1))
The motivation is that it is quite common operation and the code using it would be simpler and saving one allocation.
Alternatively, please consider AddInt(64) and SubInt(64), which would still save one allocation when knowing the increment/decrement fits a (64-bit) machine word.
Cursory look at Go source shows that the first alternative could be useful here and here, and the second one here.
Yet another alternative would be to expose intOne from int.go.
ainar-g, lmittmann, mdebjit, AlexanderMint, ryanc414 and 1 moreericlagergren