diff options
author | 2022-12-23 00:47:36 -0800 | |
---|---|---|
committer | 2022-12-23 00:48:24 -0800 | |
commit | 958504296def4d481b127ccad453e9aa8ea3f4d3 (patch) | |
tree | 99479818c38dca930dfa4df250bc6d90e05c48a1 /src/bun.js/bindings/sqlite/JSSQLStatement.cpp | |
parent | 75a3c25ff8302be18435520adf3a96c5c59da370 (diff) | |
download | bun-958504296def4d481b127ccad453e9aa8ea3f4d3.tar.gz bun-958504296def4d481b127ccad453e9aa8ea3f4d3.tar.zst bun-958504296def4d481b127ccad453e9aa8ea3f4d3.zip |
Disable optimization
Diffstat (limited to 'src/bun.js/bindings/sqlite/JSSQLStatement.cpp')
-rw-r--r-- | src/bun.js/bindings/sqlite/JSSQLStatement.cpp | 123 |
1 files changed, 62 insertions, 61 deletions
diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp index 2ef32f521..efcb12355 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp @@ -191,75 +191,76 @@ static void initializeColumnNames(JSC::JSGlobalObject* lexicalGlobalObject, JSSQ if (count == 0) return; - if (count > 63) { - JSC::ObjectInitializationScope initializationScope(vm); - - // 64 is the maximum we can preallocate here - // see https://github.com/oven-sh/bun/issues/987 - JSC::JSObject* object = JSC::constructEmptyObject(lexicalGlobalObject, lexicalGlobalObject->objectPrototype(), std::min(count, 64)); - - for (int i = 0; i < count; i++) { - const char* name = sqlite3_column_name(stmt, i); + // if (count > 63) { + JSC::ObjectInitializationScope initializationScope(vm); - if (name == nullptr) - break; - - size_t len = strlen(name); - if (len == 0) - break; + // 64 is the maximum we can preallocate here + // see https://github.com/oven-sh/bun/issues/987 + JSC::JSObject* object = JSC::constructEmptyObject(lexicalGlobalObject, lexicalGlobalObject->objectPrototype(), std::min(count, 64)); - auto wtfString = WTF::String::fromUTF8(name, len); - auto str = JSValue(jsString(vm, wtfString)); - auto key = str.toPropertyKey(lexicalGlobalObject); - JSC::JSValue primitive = JSC::jsUndefined(); - auto decl = sqlite3_column_decltype(stmt, i); - if (decl != nullptr) { - switch (decl[0]) { - case 'F': - case 'D': - case 'I': { - primitive = jsNumber(0); - break; - } - case 'V': - case 'T': { - primitive = jsEmptyString(vm); - break; - } - } - } + for (int i = 0; i < count; i++) { + const char* name = sqlite3_column_name(stmt, i); - object->putDirect(vm, key, primitive, 0); - castedThis->columnNames->add(key); - } - castedThis->_prototype.set(vm, castedThis, object); - } else { - // 64 is the maximum we can preallocate here - // see https://github.com/oven-sh/bun/issues/987 - auto& globalObject = *lexicalGlobalObject; - Structure* structure = globalObject.structureCache().emptyObjectStructureForPrototype(&globalObject, globalObject.objectPrototype(), count); - PropertyOffset offset; + if (name == nullptr) + break; - for (int i = 0; i < count; i++) { - const char* name = sqlite3_column_name(stmt, i); + size_t len = strlen(name); + if (len == 0) + break; - if (name == nullptr) + auto wtfString = WTF::String::fromUTF8(name, len); + auto str = JSValue(jsString(vm, wtfString)); + auto key = str.toPropertyKey(lexicalGlobalObject); + JSC::JSValue primitive = JSC::jsUndefined(); + auto decl = sqlite3_column_decltype(stmt, i); + if (decl != nullptr) { + switch (decl[0]) { + case 'F': + case 'D': + case 'I': { + primitive = jsNumber(0); break; - - size_t len = strlen(name); - if (len == 0) + } + case 'V': + case 'T': { + primitive = jsEmptyString(vm); break; - - auto wtfString = WTF::String::fromUTF8(name, len); - auto str = JSValue(jsString(vm, wtfString)); - auto key = str.toPropertyKey(lexicalGlobalObject); - structure = Structure::addPropertyTransition(vm, structure, key, 0, offset); - castedThis->columnNames->add(key); + } + } } - castedThis->_structure.set(vm, castedThis, structure); - JSC::JSObject* object = JSC::constructEmptyObject(vm, structure); - castedThis->_prototype.set(vm, castedThis, object); - } + + object->putDirect(vm, key, primitive, 0); + castedThis->columnNames->add(key); + } + castedThis->_prototype.set(vm, castedThis, object); + // TODO: Re-enable after https://github.com/oven-sh/bun/issues/1646 is fixed + // } else { + // // 64 is the maximum we can preallocate here + // // see https://github.com/oven-sh/bun/issues/987 + // auto& globalObject = *lexicalGlobalObject; + // Structure* structure = globalObject.structureCache().emptyObjectStructureForPrototype(&globalObject, globalObject.objectPrototype(), count); + // PropertyOffset offset; + + // for (int i = 0; i < count; i++) { + // const char* name = sqlite3_column_name(stmt, i); + + // if (name == nullptr) + // break; + + // size_t len = strlen(name); + // if (len == 0) + // break; + + // auto wtfString = WTF::String::fromUTF8(name, len); + // auto str = JSValue(jsString(vm, wtfString)); + // auto key = str.toPropertyKey(lexicalGlobalObject); + // structure = Structure::addPropertyTransition(vm, structure, key, 0, offset); + // castedThis->columnNames->add(key); + // } + // castedThis->_structure.set(vm, castedThis, structure); + // JSC::JSObject* object = JSC::constructEmptyObject(vm, structure); + // castedThis->_prototype.set(vm, castedThis, object); + // } } void JSSQLStatement::destroy(JSC::JSCell* cell) |