| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index b5e78d3da0b6e884cff93829f4b71b0222e68a90..3fc957a28037b9533bc1faa559c79454d21ce9bb 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -14488,32 +14488,7 @@ size_t JSTypedArray::element_size() {
|
| Object* ExternalUint8ClampedArray::SetValue(uint32_t index, Object* value) {
|
| uint8_t clamped_value = 0;
|
| if (index < static_cast<uint32_t>(length())) {
|
| - if (value->IsSmi()) {
|
| - int int_value = Smi::cast(value)->value();
|
| - if (int_value < 0) {
|
| - clamped_value = 0;
|
| - } else if (int_value > 255) {
|
| - clamped_value = 255;
|
| - } else {
|
| - clamped_value = static_cast<uint8_t>(int_value);
|
| - }
|
| - } else if (value->IsHeapNumber()) {
|
| - double double_value = HeapNumber::cast(value)->value();
|
| - if (!(double_value > 0)) {
|
| - // NaN and less than zero clamp to zero.
|
| - clamped_value = 0;
|
| - } else if (double_value > 255) {
|
| - // Greater than 255 clamp to 255.
|
| - clamped_value = 255;
|
| - } else {
|
| - // Other doubles are rounded to the nearest integer.
|
| - clamped_value = static_cast<uint8_t>(lrint(double_value));
|
| - }
|
| - } else {
|
| - // Clamp undefined to zero (default). All other types have been
|
| - // converted to a number type further up in the call chain.
|
| - ASSERT(value->IsUndefined());
|
| - }
|
| + clamped_value = clampObjectToUint8(value);
|
| set(index, clamped_value);
|
| }
|
| return Smi::FromInt(clamped_value);
|
|
|