1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Internal JS cleanups. Correct part of [ac136925a645] to account for the eTextRep flag being able to hold flags other than the encoding.

FossilOrigin-Name: 1dfc03ab1e0269807beef27bf884ab9ead7553d4a5f6ed213f812d7fa052045f
This commit is contained in:
stephan
2022-12-23 21:10:49 +00:00
parent 3705f38ab0
commit ab9c2d571e
7 changed files with 90 additions and 81 deletions

View File

@ -1277,28 +1277,13 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
so we have no range checking. */
f._ = {
string: function(stmt, ndx, val, asBlob){
if(1){
/* _Hypothetically_ more efficient than the impl in the 'else' block. */
const stack = wasm.scopedAllocPush();
try{
const n = wasm.jstrlen(val);
const pStr = wasm.scopedAlloc(n);
wasm.jstrcpy(val, wasm.heap8u(), pStr, n, false);
const f = asBlob ? capi.sqlite3_bind_blob : capi.sqlite3_bind_text;
return f(stmt.pointer, ndx, pStr, n, capi.SQLITE_TRANSIENT);
}finally{
wasm.scopedAllocPop(stack);
}
}else{
const bytes = wasm.jstrToUintArray(val,false);
const pStr = wasm.alloc(bytes.length || 1);
wasm.heap8u().set(bytes.length ? bytes : [0], pStr);
try{
const f = asBlob ? capi.sqlite3_bind_blob : capi.sqlite3_bind_text;
return f(stmt.pointer, ndx, pStr, bytes.length, capi.SQLITE_TRANSIENT);
}finally{
wasm.dealloc(pStr);
}
const stack = wasm.scopedAllocPush();
try{
const [pStr, n] = wasm.scopedAllocCString(val, true);
const f = asBlob ? capi.sqlite3_bind_blob : capi.sqlite3_bind_text;
return f(stmt.pointer, ndx, pStr, n, capi.SQLITE_TRANSIENT);
}finally{
wasm.scopedAllocPop(stack);
}
}
};
@ -1354,7 +1339,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
const pBlob = wasm.scopedAlloc(val.byteLength || 1);
wasm.heap8().set(val.byteLength ? val : [0], pBlob)
rc = capi.sqlite3_bind_blob(stmt.pointer, ndx, pBlob, val.byteLength,
capi.SQLITE_TRANSIENT);
capi.SQLITE_TRANSIENT);
}finally{
wasm.scopedAllocPop(stack);
}