nim-lang / bigints

BigInts for Nim
MIT License
124 stars 32 forks source link

Optimize `succ`/`dec` for 32 bit values #83

Closed konsumlamm closed 2 years ago

konsumlamm commented 2 years ago

This uses inc/dec if b is in the range of int32 (which avoids allocating a temporary BigInt), at the cost of an additonal range check. I chose to not change the type from int to int32, since succ/prec for Ordinals also take an int (we might want to make inc/dec take an int as well for the same reason). Although if you prefer taking an int32, I can happily change that.