зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1685708 - Part 1: Handle no-op cases for 64-bit results in Big.as{Uint,Int}N. r=jandem
The fast path didn't handle the no-op case, which actually made the fast-path slower for the case when no conversion is necessary. Differential Revision: https://phabricator.services.mozilla.com/D101167
This commit is contained in:
Родитель
7545ed9378
Коммит
afb27b46a3
|
@ -2588,7 +2588,11 @@ BigInt* BigInt::asUintN(JSContext* cx, HandleBigInt x, uint64_t bits) {
|
|||
if (bits <= 64) {
|
||||
uint64_t u64 = toUint64(x);
|
||||
uint64_t mask = uint64_t(-1) >> (64 - bits);
|
||||
return createFromUint64(cx, u64 & mask);
|
||||
uint64_t n = u64 & mask;
|
||||
if (u64 == n && x->absFitsInUint64()) {
|
||||
return x;
|
||||
}
|
||||
return createFromUint64(cx, n);
|
||||
}
|
||||
|
||||
if (bits >= MaxBitLength) {
|
||||
|
@ -2645,7 +2649,11 @@ BigInt* BigInt::asIntN(JSContext* cx, HandleBigInt x, uint64_t bits) {
|
|||
}
|
||||
|
||||
if (bits == 64) {
|
||||
return createFromInt64(cx, toInt64(x));
|
||||
int64_t n = toInt64(x);
|
||||
if (((n < 0) == x->isNegative()) && x->absFitsInUint64()) {
|
||||
return x;
|
||||
}
|
||||
return createFromInt64(cx, n);
|
||||
}
|
||||
|
||||
if (bits > MaxBitLength) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче