write: O(n) block concat without apply

ober

fe022ae9b4d9312cb531c2f891e9a6b1fca4ed45

diff --git a/protonstorage/drive/write.ss b/protonstorage/drive/write.ss
index f3f63f8..c82d353 100644
--- a/protonstorage/drive/write.ss
+++ b/protonstorage/drive/write.ss
@@ -159,9 +159,18 @@
       out))
 
   (def (concat-bytevectors bvs)
-    (if (null? bvs)
-        (make-bytevector 0)
-        (apply bytevector-append bvs)))
+    (let* ([total
+            (let loop ([xs bvs] [n 0])
+              (if (null? xs)
+                  n
+                  (loop (cdr xs) (+ n (bytevector-length (car xs))))))]
+           [out (make-bytevector total 0)])
+      (let loop ([xs bvs] [off 0])
+        (unless (null? xs)
+          (let* ([bv (car xs)] [len (bytevector-length bv)])
+            (bytevector-copy! bv 0 out off len)
+            (loop (cdr xs) (+ off len)))))
+      out))
 
   (def (split-bytevector bv block-size)
     (let ([n (bytevector-length bv)])