From f2b4d57068d13b6dc3de2ccc6550675d11d34cfa Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Fri, 1 Jul 2016 23:29:31 +0200 Subject: fusefrontend: coalesce grows in Truncate() We were growing the file block-by-block which was pretty inefficient. We now coalesce all the grows into a single Ftruncate. Also simplifies the code! Simplistic benchmark: Before: $ time truncate -s 1000M foo real 0m0.568s After: $ time truncate -s 1000M foo real 0m0.205s --- internal/contentenc/offsets.go | 1 + 1 file changed, 1 insertion(+) (limited to 'internal/contentenc') diff --git a/internal/contentenc/offsets.go b/internal/contentenc/offsets.go index da0551a..256ea26 100644 --- a/internal/contentenc/offsets.go +++ b/internal/contentenc/offsets.go @@ -66,6 +66,7 @@ func (be *ContentEnc) PlainSizeToCipherSize(plainSize uint64) uint64 { } // Split a plaintext byte range into (possibly partial) blocks +// Returns an empty slice if length == 0. func (be *ContentEnc) ExplodePlainRange(offset uint64, length uint64) []intraBlock { var blocks []intraBlock var nextBlock intraBlock -- cgit v1.2.3