aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-05-01 03:43:52 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-05-01 03:43:52 -0700
commitb6aa9887169f3cb7b7e866d8ea5544bc168dec86 (patch)
treee7cbaadd575ee7da7dd3f96a286cfa93d9f42099 /src
parenta3b48b3229b4dcdaa7c51762ceb2641d219e9a1c (diff)
downloadbun-b6aa9887169f3cb7b7e866d8ea5544bc168dec86.tar.gz
bun-b6aa9887169f3cb7b7e866d8ea5544bc168dec86.tar.zst
bun-b6aa9887169f3cb7b7e866d8ea5544bc168dec86.zip
[bun.js] Improve `Buffer` creation perf a little
Diffstat (limited to 'src')
-rw-r--r--src/javascript/jsc/bindings/JSBuffer.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/javascript/jsc/bindings/JSBuffer.cpp b/src/javascript/jsc/bindings/JSBuffer.cpp
index 7a5ea8c7b..eab0a7734 100644
--- a/src/javascript/jsc/bindings/JSBuffer.cpp
+++ b/src/javascript/jsc/bindings/JSBuffer.cpp
@@ -376,10 +376,7 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_concatBody(JSC::JS
for (size_t i = 0; i < arrayLength; i++) {
auto element = array->getIndex(lexicalGlobalObject, i);
RETURN_IF_EXCEPTION(throwScope, {});
- if (!element.isObject()) {
- throwTypeError(lexicalGlobalObject, throwScope, "Buffer.concat expects Uint8Array"_s);
- return JSValue::encode(jsUndefined());
- }
+
auto* typedArray = JSC::jsDynamicCast<JSC::JSUint8Array*>(vm, element);
if (!typedArray) {
throwTypeError(lexicalGlobalObject, throwScope, "Buffer.concat expects Uint8Array"_s);
@@ -1123,6 +1120,9 @@ void JSBufferPrototype::finishCreation(VM& vm, JSC::JSGlobalObject* globalThis)
reifyStaticProperties(vm, JSBuffer::info(), JSBufferPrototypeTableValues, *this);
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
this->setPrototypeDirect(vm, globalThis->m_typedArrayUint8.prototype(globalThis));
+ auto clientData = WebCore::clientData(vm);
+ this->putDirect(vm, clientData->builtinNames().dataViewPublicName(), JSC::jsUndefined(), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ this->putDirect(vm, clientData->builtinNames().dataViewPrivateName(), JSC::JSValue(true), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
}
const ClassInfo JSBufferPrototype::s_info = { "Buffer"_s, nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(JSBufferPrototype) };
@@ -1249,6 +1249,5 @@ static void toBuffer(JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSUint8Array
auto* dataView = JSC::JSDataView::create(lexicalGlobalObject, lexicalGlobalObject->typedArrayStructure(JSC::TypeDataView), uint8Array->possiblySharedBuffer(), uint8Array->byteOffset(), uint8Array->length());
// putDirectWithTransition doesn't work here
- object->putDirect(vm, clientData->builtinNames().dataViewPublicName(), dataView, JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
- object->putDirect(vm, clientData->builtinNames().dataViewPrivateName(), JSC::JSValue(true), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ object->putDirectWithoutTransition(vm, clientData->builtinNames().dataViewPublicName(), dataView, JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
} \ No newline at end of file