Bug 1398751 - Part 2: Add fast path to convert int32 value to a code point. r=evilpie

This commit is contained in:
André Bargull 2017-09-12 21:22:29 +02:00
Родитель 43d9783cff
Коммит 4a4936b05a
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -3312,6 +3312,16 @@ static MOZ_ALWAYS_INLINE bool
ToCodePoint(JSContext* cx, HandleValue code, uint32_t* codePoint)
{
// String.fromCodePoint, Steps 5.a-b.
// Fast path for the common case - the input is already an int32.
if (code.isInt32()) {
int32_t nextCP = code.toInt32();
if (nextCP >= 0 && nextCP <= int32_t(unicode::NonBMPMax)) {
*codePoint = uint32_t(nextCP);
return true;
}
}
double nextCP;
if (!ToNumber(cx, code, &nextCP))
return false;