Kelson has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/296547 )

Change subject: Bug fix: preserve cluster compression type after clear().
......................................................................


Bug fix: preserve cluster compression type after clear().

By nulling out the cluster implementation on clear, we were also
resetting the cluster compression type.  This caused the ZimCreator
API to not compress compressible clusters after the first one.
This is a follow-up to f5de40f94b30795f42bb9388cbb46df9cd605167,
which reused cluster objects instead of recreating them from scratch
each time.

Related issue: the `size()` of an empty cluster is actually 4, not 0,
since even an empty cluster contains an field which counts the number
of offsets in the cluster, and change the ClusterImpl initializer so
the compresion type doesn't change from zimcompNone to zimcompDefault
as soon as the ClusterImpl is created.

Change-Id: I468a1719a33c450db9a28d9704b539bdb97cd7fc
---
M zimlib/include/zim/cluster.h
M zimlib/src/cluster.cpp
2 files changed, 3 insertions(+), 3 deletions(-)

Approvals:
  Kelson: Verified; Looks good to me, approved



diff --git a/zimlib/include/zim/cluster.h b/zimlib/include/zim/cluster.h
index c26c24c..bd55cb5 100644
--- a/zimlib/include/zim/cluster.h
+++ b/zimlib/include/zim/cluster.h
@@ -88,8 +88,8 @@
       Blob getBlob(size_type n) const;
 
       size_type count() const   { return impl ? impl->getCount() : 0; }
-      size_type size() const    { return impl ? impl->getSize() : 0; }
-      void clear()              { impl = 0; }
+      size_type size() const    { return impl ? impl->getSize(): 
sizeof(size_type); }
+      void clear()              { if (impl) impl->clear(); }
 
       void addBlob(const char* data, unsigned size) { getImpl()->addBlob(data, 
size); }
       void addBlob(const Blob& blob)                { 
getImpl()->addBlob(blob); }
diff --git a/zimlib/src/cluster.cpp b/zimlib/src/cluster.cpp
index 6f6ea14..3630042 100644
--- a/zimlib/src/cluster.cpp
+++ b/zimlib/src/cluster.cpp
@@ -60,7 +60,7 @@
   }
 
   ClusterImpl::ClusterImpl()
-    : compression(zimcompDefault)
+    : compression(zimcompNone)
   {
     offsets.push_back(0);
   }

-- 
To view, visit https://gerrit.wikimedia.org/r/296547
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I468a1719a33c450db9a28d9704b539bdb97cd7fc
Gerrit-PatchSet: 3
Gerrit-Project: openzim
Gerrit-Branch: master
Gerrit-Owner: C. Scott Ananian <canan...@wikimedia.org>
Gerrit-Reviewer: Kelson <kel...@kiwix.org>
Gerrit-Reviewer: Mgautierfr <mgaut...@kymeria.fr>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to