Skip to content

Commit 317b98e

Browse files
committed
Avoid lengthBytesUTF8
1 parent 2aff403 commit 317b98e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/api.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
stackRestore
1212
stackSave
1313
UTF8ToString
14-
stringToUTF8
15-
lengthBytesUTF8
14+
stringToNewUTF8
1615
allocateUTF8OnStack
1716
removeFunction
1817
addFunction
@@ -543,14 +542,13 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
543542
pos = this.pos;
544543
this.pos += 1;
545544
}
546-
var length = lengthBytesUTF8(string);
547545
var strptr = stringToNewUTF8(string);
548546
this.allocatedmem.push(strptr);
549547
this.db.handleError(sqlite3_bind_text(
550548
this.stmt,
551549
pos,
552550
strptr,
553-
length - 1,
551+
-1,
554552
0
555553
));
556554
return true;
@@ -733,12 +731,10 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
733731
*/
734732
function StatementIterator(sql, db) {
735733
this.db = db;
736-
var sz = lengthBytesUTF8(sql) + 1;
737-
this.sqlPtr = _malloc(sz);
734+
this.sqlPtr = stringToNewUTF8(sql);
738735
if (this.sqlPtr === null) {
739736
throw new Error("Unable to allocate memory for the SQL string");
740737
}
741-
stringToUTF8(sql, this.sqlPtr, sz);
742738
this.nextSqlPtr = this.sqlPtr;
743739
this.nextSqlString = null;
744740
this.activeStatement = null;

0 commit comments

Comments
 (0)