Explorar o código

Merge pull request #4183 from overleaf/jpa-use-memory-views

[perf] serviceWorker: use memory view on large chunks instead of slicing

GitOrigin-RevId: 10933b25500aebc0b236315aceca4c44089c79e6
Jakob Ackermann %!s(int64=5) %!d(string=hai) anos
pai
achega
a06031425b
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      services/web/frontend/js/serviceWorker.js

+ 1 - 1
services/web/frontend/js/serviceWorker.js

@@ -415,7 +415,7 @@ function processPdfRequest(
           if (offsetStart > 0 || offsetEnd > 0) {
           if (offsetStart > 0 || offsetEnd > 0) {
             // compute index positions for slice to handle case where offsetEnd=0
             // compute index positions for slice to handle case where offsetEnd=0
             const chunkSize = chunk.end - chunk.start
             const chunkSize = chunk.end - chunk.start
-            data = data.slice(offsetStart, chunkSize - offsetEnd)
+            data = data.subarray(offsetStart, chunkSize - offsetEnd)
           }
           }
           const insertPosition = Math.max(chunk.start - start, 0)
           const insertPosition = Math.max(chunk.start - start, 0)
           reAssembledBlob.set(data, insertPosition)
           reAssembledBlob.set(data, insertPosition)