Skip to content

Commit

Permalink
fix naming and comment
Browse files Browse the repository at this point in the history
  • Loading branch information
gvilums committed Apr 15, 2024
1 parent 54d763c commit 8d29414
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/bun.js/bindings/sqlite/JSSQLStatement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,9 @@ class JSSQLStatement : public JSC::JSDestructibleObject {
VersionSqlite3* version_db;
uint64_t version;
bool hasExecuted = false;
// Tracks which columns should be skipped because another column with the same name
// is being used instead. Each bit corresponds to a column index. If the bit is set,
// the column should be skipped.
WTF::BitVector skippedColumns;
// Tracks which columns are valid in the current result set. Used to handle duplicate column names.
// The bit at index i is set if the column at index i is valid.
WTF::BitVector validColumns;
std::unique_ptr<PropertyNameArray> columnNames;
mutable JSC::WriteBarrier<JSC::JSObject> _prototype;
mutable JSC::WriteBarrier<JSC::Structure> _structure;
Expand Down Expand Up @@ -422,7 +421,7 @@ static void initializeColumnNames(JSC::JSGlobalObject* lexicalGlobalObject, JSSQ
castedThis->columnNames->propertyNameMode(),
castedThis->columnNames->privateSymbolMode()));
}
castedThis->skippedColumns.clearAll();
castedThis->validColumns.clearAll();
castedThis->update_version();

JSC::VM& vm = lexicalGlobalObject->vm();
Expand Down Expand Up @@ -469,7 +468,7 @@ static void initializeColumnNames(JSC::JSGlobalObject* lexicalGlobalObject, JSSQ
int curCount = columnNames->size();

if (preCount != curCount) {
castedThis->skippedColumns.set(i);
castedThis->validColumns.set(i);
}
}

Expand All @@ -496,7 +495,7 @@ static void initializeColumnNames(JSC::JSGlobalObject* lexicalGlobalObject, JSSQ
castedThis->columnNames->propertyNameMode(),
castedThis->columnNames->privateSymbolMode()));
// castedThis->columnOffsets = 0;
castedThis->skippedColumns.clearAll();
castedThis->validColumns.clearAll();
}
}

Expand Down Expand Up @@ -545,7 +544,7 @@ static void initializeColumnNames(JSC::JSGlobalObject* lexicalGlobalObject, JSSQ

// only put the property if it's not a duplicate
if (preCount != curCount) {
castedThis->skippedColumns.set(i);
castedThis->validColumns.set(i);
object->putDirect(vm, key, primitive, 0);
}
}
Expand Down Expand Up @@ -1381,7 +1380,7 @@ static inline JSC::JSValue constructResultObject(JSC::JSGlobalObject* lexicalGlo
// i: the index of columns returned from SQLite
// j: the index of object property
for (int i = 0, j = 0; j < count; i++, j++) {
if (!castedThis->skippedColumns.get(i)) {
if (!castedThis->validColumns.get(i)) {
// this column is duplicate, skip
j -= 1;
continue;
Expand Down Expand Up @@ -1443,7 +1442,7 @@ static inline JSC::JSValue constructResultObject(JSC::JSGlobalObject* lexicalGlo
}

for (int i = 0, j = 0; j < count; i++, j++) {
if (!castedThis->skippedColumns.get(i)) {
if (!castedThis->validColumns.get(i)) {
j -= 1;
continue;
}
Expand Down Expand Up @@ -1506,7 +1505,7 @@ static inline JSC::JSArray* constructResultRow(JSC::JSGlobalObject* lexicalGloba
auto* stmt = castedThis->stmt;

for (int i = 0, j = 0; j < count; i++, j++) {
if (!castedThis->skippedColumns.get(i)) {
if (!castedThis->validColumns.get(i)) {
j -= 1;
continue;
}
Expand Down

0 comments on commit 8d29414

Please sign in to comment.