-
-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize integer operations #1147
Comments
@HalidOdat I see you assigned yourself this issue, let me know if you're still working on it, or if we can un-assign it :) |
I didn't implement this because it would make #1373 harder/impossible since integer and rational has will be encoded |
Still, having integer operations optimized would be a good thing, right? Do you see a way we could get this? An option might be to use untagged enums (unions) or somehow add different |
We are still going to have integer and rational variants, we wont remove them! But they have to be flat (since the tag is encoded with the payload, all in a 64bit value), we can't nest it (the current implementation is this way anyway). |
As said in #1964, while it makes some work in this area I still believe more could be done inside |
We can close this from the fact that we already have optimizations to preserve integers on general operations like sums, subtractions, mod, etc. |
Increment operators on
Value::Integer(i32)
s result inValue::Rational(f64)
s because they useValue::to_number
which returnsf64
. This makes traditionalfor
loops withi++
slower because they use floating point arithmetic rather than integer arithmetic.My idea
I thought a good solution would be to have an internal:
We would also simplify to have a single
Value
variant for number rather than the current duo ofValue::Rational
andValue::Integer
.This would be the new return type of
Value::to_number
using theint
variant when possible. It would also probably be a good fit tor theNumber
variant ofObjectData
.Open to other ideas 💡
The text was updated successfully, but these errors were encountered: