Open
Description
Currently, BigInt
is defined as follows:
type
BigInt* = object
limbs: seq[uint32]
isNegative: bool
It has the invariant that limbs.len >= 1
.
It might be worth it changing that to
type
BigInt* = object
limbs: seq[uint32]
first: uint32
isNegative: bool
This has several advantages:
- The invariant is now always satisfied (the first limb always exists).
- Small
BigInt
s require no allocation & pointer indirection. - It would avoid special casing 0 (see Empty limbs when uninitialized #26).
Disadvantages:
- A bit more special handling is needed.
- The first limb not being next to the other limbs in memory may make a difference (but I doubt it would be noticable).
Metadata
Metadata
Assignees
Labels
No labels