You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: