Skip to content

Commit

Permalink
Merge branch 'fix/async_loading' into wasm
Browse files Browse the repository at this point in the history
* fix/async_loading:
  Commit the latest compiled assets
  Don't use writeStringToMemory
  • Loading branch information
Taytay committed Nov 4, 2018
2 parents 53c1c63 + 508cf1a commit ee90d9f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 425 deletions.
11 changes: 7 additions & 4 deletions coffee/api.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apiTemp = stackAlloc(4)
# Constants are defined in api-data.coffee
SQLite = {}

### Represents an prepared statement.
### Represents a prepared statement.
Prepared statements allow you to have a template sql string,
that you can execute multiple times with different parameters.
Expand Down Expand Up @@ -311,11 +311,14 @@ class Database
if not @db then throw "Database closed"

stack = stackSave()

# Store the SQL string in memory. The string will be consumed, one statement
# at a time, by sqlite3_prepare_v2_sqlptr.
# Allocate at most 4 bytes per UTF8 char, +1 for the trailing '\0'
nextSqlPtr = stackAlloc(sql.length<<2 + 1)
writeStringToMemory sql, nextSqlPtr
# Note that if we want to allocate as much memory as could _possibly_ be used, we can
# we allocate bytes equal to 4* the number of chars in the sql string.
# It would be faster, but this is probably a premature optimization
nextSqlPtr = allocateUTF8OnStack(sql)

# Used to store a pointer to the next SQL statement in the string
pzTail = stackAlloc(4)

Expand Down
5 changes: 2 additions & 3 deletions js/sql-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ apiTemp = stackAlloc(4);
SQLite = {};


/* Represents an prepared statement.
/* Represents a prepared statement.

Prepared statements allow you to have a template sql string,
that you can execute multiple times with different parameters.
Expand Down Expand Up @@ -513,8 +513,7 @@ Database = (function() {
throw "Database closed";
}
stack = stackSave();
nextSqlPtr = stackAlloc(sql.length << 2 + 1);
writeStringToMemory(sql, nextSqlPtr);
nextSqlPtr = allocateUTF8OnStack(sql);
pzTail = stackAlloc(4);
results = [];
while (getValue(nextSqlPtr, 'i8') !== NULL) {
Expand Down
145 changes: 6 additions & 139 deletions js/sql-memory-growth.js

Large diffs are not rendered by default.

144 changes: 6 additions & 138 deletions js/sql.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions js/worker.sql-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ apiTemp = stackAlloc(4);
SQLite = {};


/* Represents an prepared statement.
/* Represents a prepared statement.

Prepared statements allow you to have a template sql string,
that you can execute multiple times with different parameters.
Expand Down Expand Up @@ -513,8 +513,7 @@ Database = (function() {
throw "Database closed";
}
stack = stackSave();
nextSqlPtr = stackAlloc(sql.length << 2 + 1);
writeStringToMemory(sql, nextSqlPtr);
nextSqlPtr = allocateUTF8OnStack(sql);
pzTail = stackAlloc(4);
results = [];
while (getValue(nextSqlPtr, 'i8') !== NULL) {
Expand Down
144 changes: 6 additions & 138 deletions js/worker.sql.js

Large diffs are not rendered by default.

0 comments on commit ee90d9f

Please sign in to comment.