-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Appending to a slice is slower than allocating beforehand, and directly changing the value of slice[i].
The issue is getting a reliable way to know how big to make the slice. Hypothetically, a slice can only have up to the maximum of the value of int, but allocating that much space may be a waste.
As it turns out, in order to know the exact number of digits a fraction will have, knowing the factors of the base and denominator are needed. The base's factors can be determined when the Formatter is initialized, but for the denominator it might be slow.
May have to do benchmarks to see if it's actually faster, but first need to figure out how to go about it.