File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ apiTemp = stackAlloc(4)
5
5
# Constants are defined in api-data.coffee
6
6
SQLite = {}
7
7
8
- ### Represents an prepared statement.
8
+ ### Represents a prepared statement.
9
9
10
10
Prepared statements allow you to have a template sql string,
11
11
that you can execute multiple times with different parameters.
@@ -311,11 +311,14 @@ class Database
311
311
if not @db then throw " Database closed"
312
312
313
313
stack = stackSave ()
314
+
314
315
# Store the SQL string in memory. The string will be consumed, one statement
315
316
# at a time, by sqlite3_prepare_v2_sqlptr.
316
- # Allocate at most 4 bytes per UTF8 char, +1 for the trailing '\0'
317
- nextSqlPtr = stackAlloc (sql .length << 2 + 1 )
318
- writeStringToMemory sql, nextSqlPtr
317
+ # Note that if we want to allocate as much memory as could _possibly_ be used, we can
318
+ # we allocate bytes equal to 4* the number of chars in the sql string.
319
+ # It would be faster, but this is probably a premature optimization
320
+ nextSqlPtr = allocateUTF8OnStack (sql)
321
+
319
322
# Used to store a pointer to the next SQL statement in the string
320
323
pzTail = stackAlloc (4 )
321
324
You can’t perform that action at this time.
0 commit comments