[Pkg-mozext-commits] [adblock-plus] 21/28: Issue 1510 - Stop using OS.File.readTo()

David Prévot taffit at moszumanska.debian.org
Wed Nov 12 02:09:57 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit 5aabb9b77cf6980fe3597ff02dee02fc0572e1d7
Author: Wladimir Palant <trev at adblockplus.org>
Date:   Thu Oct 30 23:02:35 2014 +0100

    Issue 1510 - Stop using OS.File.readTo()
---
 lib/io.js | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/lib/io.js b/lib/io.js
index f054fb3..3c74a82 100644
--- a/lib/io.js
+++ b/lib/io.js
@@ -28,7 +28,7 @@ let {Prefs} = require("prefs");
 let {Utils} = require("utils");
 
 let firstRead = true;
-const BUFFER_SIZE = 0x8000;  // 32kB
+const BUFFER_SIZE = 0x80000;  // 512kB
 
 let IO = exports.IO =
 {
@@ -150,7 +150,6 @@ let IO = exports.IO =
       };
 
       let decoder = new TextDecoder();
-      let array = new Uint8Array(BUFFER_SIZE);
       Task.spawn(function()
       {
         if (firstRead && Services.vc.compare(Utils.platformVersion, "23.0a1") <= 0)
@@ -173,19 +172,15 @@ let IO = exports.IO =
         firstRead = false;
 
         let f = yield OS.File.open(file.path, {read: true});
-        let numBytes;
-        do
+        while (true)
         {
-          numBytes = yield f.readTo(array);
-          if (numBytes)
-          {
-            let data = decoder.decode(numBytes == BUFFER_SIZE ?
-                                      array :
-                                      array.subarray(0, numBytes), {stream: true});
-            onProgress(data);
-          }
-        } while (numBytes);
+          let array = yield f.read(BUFFER_SIZE);
+          if (!array.length)
+            break;
 
+          let data = decoder.decode(array, {stream: true});
+          onProgress(data);
+        }
         yield f.close();
       }.bind(this)).then(onSuccess, onError);
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list