@@ -55157,7 +55157,8 @@ static JSValue js_dataview_getValue(JSContext *ctx,
55157
55157
{
55158
55158
JSTypedArray *ta;
55159
55159
JSArrayBuffer *abuf;
55160
- int is_swap, size;
55160
+ BOOL littleEndian, is_swap;
55161
+ int size;
55161
55162
uint8_t *ptr;
55162
55163
uint32_t v;
55163
55164
uint64_t pos;
@@ -55168,9 +55169,8 @@ static JSValue js_dataview_getValue(JSContext *ctx,
55168
55169
size = 1 << typed_array_size_log2(class_id);
55169
55170
if (JS_ToIndex(ctx, &pos, argv[0]))
55170
55171
return JS_EXCEPTION;
55171
- is_swap = TRUE;
55172
- if (argc > 1)
55173
- is_swap = !JS_ToBool(ctx, argv[1]);
55172
+ littleEndian = argc > 1 && JS_ToBool(ctx, argv[1]);
55173
+ is_swap = littleEndian ^ !is_be();
55174
55174
abuf = ta->buffer->u.array_buffer;
55175
55175
if (abuf->detached)
55176
55176
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
@@ -55255,7 +55255,8 @@ static JSValue js_dataview_setValue(JSContext *ctx,
55255
55255
{
55256
55256
JSTypedArray *ta;
55257
55257
JSArrayBuffer *abuf;
55258
- int is_swap, size;
55258
+ BOOL littleEndian, is_swap;
55259
+ int size;
55259
55260
uint8_t *ptr;
55260
55261
uint64_t v64;
55261
55262
uint32_t v;
@@ -55294,9 +55295,8 @@ static JSValue js_dataview_setValue(JSContext *ctx,
55294
55295
v64 = u.u64;
55295
55296
}
55296
55297
}
55297
- is_swap = TRUE;
55298
- if (argc > 2)
55299
- is_swap = !JS_ToBool(ctx, argv[2]);
55298
+ littleEndian = argc > 2 && JS_ToBool(ctx, argv[2]);
55299
+ is_swap = littleEndian ^ !is_be();
55300
55300
abuf = ta->buffer->u.array_buffer;
55301
55301
if (abuf->detached)
55302
55302
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
0 commit comments