diff options
author | stephan <stephan@noemail.net> | 2022-12-23 21:23:26 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-12-23 21:23:26 +0000 |
commit | bb769f0b4a025761fa2f5150582cf7736cb14345 (patch) | |
tree | 23c7c0643f8a95efcbaf728af8b7bba0057c0cd5 /ext/wasm/api/sqlite3-api-oo1.js | |
parent | 77eac0507c7f36a50814336fb1da6a5c3923ffec (diff) | |
parent | ab9c2d571e5927060c65d7bfd3132348f6240159 (diff) | |
download | sqlite-bb769f0b4a025761fa2f5150582cf7736cb14345.tar.gz sqlite-bb769f0b4a025761fa2f5150582cf7736cb14345.zip |
Merge trunk into wasm-session-api branch.
FossilOrigin-Name: 6cdb036d8e8c5ddb0c6578aeefe318e74d7a90228e57b9f9047057dae3252963
Diffstat (limited to 'ext/wasm/api/sqlite3-api-oo1.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-oo1.js | 31 |
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); } |