File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -34,11 +34,12 @@ export function Factory(Module) {
3434 const tmp = Module . _malloc ( 8 ) ;
3535 const tmpPtr = [ tmp , tmp + 4 ] ;
3636
37+ const textEncoder = new TextEncoder ( ) ;
3738 // Convert a JS string to a C string. sqlite3_malloc is used to allocate
3839 // memory (use sqlite3_free to deallocate).
3940 function createUTF8 ( s ) {
4041 if ( typeof s !== 'string' ) return 0 ;
41- const utf8 = new TextEncoder ( ) . encode ( s ) ;
42+ const utf8 = textEncoder . encode ( s ) ;
4243 const zts = Module . _sqlite3_malloc ( utf8 . byteLength + 1 ) ;
4344 Module . HEAPU8 . set ( utf8 , zts ) ;
4445 Module . HEAPU8 [ zts + utf8 . byteLength ] = 0 ;
@@ -661,7 +662,7 @@ export function Factory(Module) {
661662 const onFinally = [ ] ;
662663 try {
663664 // Encode SQL string to UTF-8.
664- const utf8 = new TextEncoder ( ) . encode ( sql ) ;
665+ const utf8 = textEncoder . encode ( sql ) ;
665666
666667 // Copy encoded string to WebAssembly memory. The SQLite docs say
667668 // zero-termination is a minor optimization so add room for that.
You can’t perform that action at this time.
0 commit comments