aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-oo1.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-12-23 21:10:49 +0000
committerstephan <stephan@noemail.net>2022-12-23 21:10:49 +0000
commitab9c2d571e5927060c65d7bfd3132348f6240159 (patch)
tree7d3826617a42d79d14be1d32ed6cbf1a4135927a /ext/wasm/api/sqlite3-api-oo1.js
parent3705f38ab0a22187fd019e431c280cb82eca1165 (diff)
downloadsqlite-ab9c2d571e5927060c65d7bfd3132348f6240159.tar.gz
sqlite-ab9c2d571e5927060c65d7bfd3132348f6240159.zip
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
Diffstat (limited to 'ext/wasm/api/sqlite3-api-oo1.js')
-rw-r--r--ext/wasm/api/sqlite3-api-oo1.js31
1 files changed, 8 insertions, 23 deletions
diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js
index 59ecf56b9..1776cb327 100644
--- a/ext/wasm/api/sqlite3-api-oo1.js
+++ b/ext/wasm/api/sqlite3-api-oo1.js
@@ -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);
}