]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Micro-optimizations in opfs-sahpool.
authorstephan <stephan@noemail.net>
Sun, 16 Jul 2023 11:49:18 +0000 (11:49 +0000)
committerstephan <stephan@noemail.net>
Sun, 16 Jul 2023 11:49:18 +0000 (11:49 +0000)
FossilOrigin-Name: 52f23db948ae9694df69c00177b85cb569e9b211350a4a2dbf249e7cd8de700c

ext/wasm/api/sqlite3-opfs-async-proxy.js
ext/wasm/api/sqlite3-vfs-opfs-sahpool.js
manifest
manifest.uuid

index 179a8163586a3d20f2fe1a02b98ced04b8809b9e..cafd296c61bf8add8f97d95efc17b43978f09335 100644 (file)
@@ -35,6 +35,9 @@
 
   https://developer.chrome.com/blog/sync-methods-for-accesshandles/
 
+  Firefox v111 and Safari 16.4, both released in March 2023, also
+  include this.
+
   We cannot change to the sync forms at this point without breaking
   clients who use Chrome v104-ish or higher. truncate(), getSize(),
   flush(), and close() are now (as of v108) synchronous. Calling them
index 0551523101c7ced15b1af75f4ea19899e61990a9..163544f91572d2ba7964dc006ee3741ca587fc21 100644 (file)
@@ -275,32 +275,33 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
        returns an empty string.
     */
     getAssociatedPath: function(sah){
-      const body = this.apBody;
-      sah.read(body, {at: 0});
+      sah.read(this.apBody, {at: 0});
       // Delete any unexpected files left over by previous
       // untimely errors...
-      const dv = new DataView(body.buffer, body.byteOffset);
-      const flags = dv.getUint32(HEADER_OFFSET_FLAGS);
-      if(body[0] &&
+      const flags = this.dvBody.getUint32(HEADER_OFFSET_FLAGS);
+      if(this.apBody[0] &&
          ((flags & capi.SQLITE_OPEN_DELETEONCLOSE) ||
           (flags & PERSISTENT_FILE_TYPES)===0)){
-        warn(`Removing file with unexpected flags ${flags.toString(16)}`);
+        warn(`Removing file with unexpected flags ${flags.toString(16)}`,
+            this.apBody);
         this.setAssociatedPath(sah, '', 0);
         return '';
       }
 
       const fileDigest = new Uint32Array(HEADER_DIGEST_SIZE / 4);
       sah.read(fileDigest, {at: HEADER_OFFSET_DIGEST});
-      const compDigest = this.computeDigest(body);
+      const compDigest = this.computeDigest(this.apBody);
       if(fileDigest.every((v,i) => v===compDigest[i])){
         // Valid digest
-        const pathBytes = body.findIndex((v)=>0===v);
+        const pathBytes = this.apBody.findIndex((v)=>0===v);
         if(0===pathBytes){
           // This file is unassociated, so truncate it to avoid
           // leaving stale db data laying around.
           sah.truncate(HEADER_OFFSET_DATA);
         }
-        return this.textDecoder.decode(body.subarray(0,pathBytes));
+        return pathBytes
+          ? this.textDecoder.decode(this.apBody.subarray(0,pathBytes))
+          : '';
       }else{
         // Invalid digest
         warn('Disassociating file with bad digest.');
@@ -313,17 +314,15 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
        flags into the given SAH.
     */
     setAssociatedPath: function(sah, path, flags){
-      const body = this.apBody;
-      const enc = this.textEncoder.encodeInto(path, body);
+      const enc = this.textEncoder.encodeInto(path || '\0', this.apBody);
       if(HEADER_MAX_PATH_SIZE <= enc.written){
         toss("Path too long:",path);
       }
 
-      const dv = new DataView(body.buffer, body.byteOffset);
-      dv.setUint32(HEADER_OFFSET_FLAGS, flags);
+      this.dvBody.setUint32(HEADER_OFFSET_FLAGS, flags);
 
-      const digest = this.computeDigest(body);
-      sah.write(body, {at: 0});
+      const digest = this.computeDigest(this.apBody);
+      sah.write(this.apBody, {at: 0});
       sah.write(digest, {at: HEADER_OFFSET_DIGEST});
       sah.flush();
 
@@ -414,6 +413,8 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
     }
 
   })/*SAHPool*/;
+  SAHPool.dvBody =
+    new DataView(SAHPool.apBody.buffer, SAHPool.apBody.byteOffset);
   //sqlite3.SAHPool = SAHPool/*only for testing*/;
   /**
      Impls for the sqlite3_io_methods methods. Maintenance reminder:
index 78b72b420fb941757e17f6cce17dd8f3e27989b9..a17a7271a1845b736eefd951e99ae760cd840b54 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Redefine\swhat\sthe\sopfs-sahpool\sinstallation\spromise\sresolves\sto.\sFix\saddCapacity().\sAdd\sutility\smethods\sto\simport/export\sfiles.
-D 2023-07-16T10:02:41.870
+C Micro-optimizations\sin\sopfs-sahpool.
+D 2023-07-16T11:49:18.318
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -500,9 +500,9 @@ F ext/wasm/api/sqlite3-api-oo1.js 9678dc4d9a5d39632b6ffe6ea94a023119260815bf32f2
 F ext/wasm/api/sqlite3-api-prologue.js 5dcb5d2d74269545073eec197614b86bd28950132b5fe4de67c10a8a0d5524b2
 F ext/wasm/api/sqlite3-api-worker1.js 9f32af64df1a031071912eea7a201557fe39b1738645c0134562bb84e88e2fec
 F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89
-F ext/wasm/api/sqlite3-opfs-async-proxy.js 961bbc3ccc1fa4e91d6519a96e8811ad7ae60173bd969fee7775dacb6eee1da2
+F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379
 F ext/wasm/api/sqlite3-v-helper.js e5c202a9ecde9ef818536d3f5faf26c03a1a9f5192b1ddea8bdabf30d75ef487
-F ext/wasm/api/sqlite3-vfs-opfs-sahpool.js 0e982cc4f1b9ed4786086d1115e740b7efd628de5cbaf16caf3a71913f91241b
+F ext/wasm/api/sqlite3-vfs-opfs-sahpool.js ba799928d945e35c97696005c4911c32f38ba4290168a1fcf0109aea6a2ba19b
 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js a5c3195203e6085d7aa89fae4b84cf3f3eec4ff4f928c6d0e5d3ef8b14cbc1c0
 F ext/wasm/api/sqlite3-wasm.c 12a096d8e58a0af0589142bae5a3c27a0c7e19846755a1a37d2c206352fbedda
 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bc06df0d599e625bde6a10a394e326dc68da9ff07fa5404354580f81566e591f
@@ -2044,8 +2044,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 279e09070918dab7b60c39179ebb7eb931ca6bd4e589b414f436740499a2f910
-R 3700fe28ac7e053b813d4612e5083eb3
+P 809c6f4de3653ad7a7751af45a7a0d6cb20c3ee3be80c69833c729242227d970
+R 025c645f0a348eef018e7d822fdbac9d
 U stephan
-Z 2285d7e58406d05c66733e55ed60721b
+Z a785870b274d18ca6df0df66a08dd418
 # Remove this line to create a well-formed Fossil manifest.
index 3cd58eacd03723307aceb4783d073673053f79dd..771b243369da266ae2b22efaf5698854ce9a1a37 100644 (file)
@@ -1 +1 @@
-809c6f4de3653ad7a7751af45a7a0d6cb20c3ee3be80c69833c729242227d970
\ No newline at end of file
+52f23db948ae9694df69c00177b85cb569e9b211350a4a2dbf249e7cd8de700c
\ No newline at end of file