]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
compressor/snappy: style cleanup
authorSage Weil <sage@redhat.com>
Mon, 6 Jun 2016 21:22:51 +0000 (17:22 -0400)
committerSage Weil <sage@redhat.com>
Wed, 15 Jun 2016 19:25:30 +0000 (15:25 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/compressor/snappy/SnappyCompressor.h

index 7dcb0bd09d5b1c0e6e2d8aff2a2c34bf6742947c..38a345a1f27a5697137d5421f2bc9ee7fa3ce017 100644 (file)
 #include "compressor/Compressor.h"
 
 class CEPH_BUFFER_API BufferlistSource : public snappy::Source {
-
   bufferlist::iterator pb;
   size_t remaining;
 
  public:
-  explicit BufferlistSource(bufferlist::iterator _pb, size_t _input_len): pb(_pb), remaining(_input_len) {
-    remaining = MIN(remaining, pb.get_remaining());
+  explicit BufferlistSource(bufferlist::iterator _pb, size_t _input_len)
+    : pb(_pb),
+      remaining(_input_len) {
+    remaining = std::min(remaining, (size_t)pb.get_remaining());
+  }
+  size_t Available() const override {
+    return remaining;
   }
-  virtual ~BufferlistSource() {}
-  virtual size_t Available() const { return remaining; }
-  virtual const char* Peek(size_t* len) {
-    const char* data = NULL;
+  const char *Peek(size_t *len) override {
+    const char *data = NULL;
     *len = 0;
     size_t avail = Available();
-    if(avail) {
+    if (avail) {
       auto ptmp = pb;
       *len = ptmp.get_ptr_and_advance(avail, &data);
     }
     return data;
   }
-  virtual void Skip(size_t n) {
+  void Skip(size_t n) override {
     assert(n <= remaining);
     pb.advance(n);
     remaining -= n;
   }
-  bufferlist::iterator get_pos() const { return pb; }
+
+  bufferlist::iterator get_pos() const {
+    return pb;
+  }
 };
 
 class SnappyCompressor : public Compressor {
  public:
   SnappyCompressor() : Compressor("snappy") {}
+
   int compress(const bufferlist &src, bufferlist &dst) override {
     BufferlistSource source(const_cast<bufferlist&>(src).begin(), src.length());
     bufferptr ptr = buffer::create_page_aligned(
       snappy::MaxCompressedLength(src.length()));
     snappy::UncheckedByteArraySink sink(ptr.c_str());
     snappy::Compress(&source, &sink);
-    dst.append(ptr, 0, sink.CurrentDestination()-ptr.c_str());
+    dst.append(ptr, 0, sink.CurrentDestination() - ptr.c_str());
     return 0;
   }
+
   int decompress(const bufferlist &src, bufferlist &dst) override {
     bufferlist::iterator i = const_cast<bufferlist&>(src).begin();
     return decompress(i, src.length(), dst);
   }
-  int decompress(bufferlist::iterator &p, size_t compressed_len, bufferlist &dst) override {
+
+  int decompress(bufferlist::iterator &p,
+                size_t compressed_len,
+                bufferlist &dst) override {
     size_t res_len = 0;
     // Trick, decompress only need first 32bits buffer
     bufferlist::const_iterator ptmp = p;
     bufferlist tmp;
     ptmp.copy(4, tmp);
-    if (!snappy::GetUncompressedLength(tmp.c_str(), tmp.length(), &res_len))
+    if (!snappy::GetUncompressedLength(tmp.c_str(), tmp.length(), &res_len)) {
       return -1;
+    }
     BufferlistSource source(p, compressed_len);
     bufferptr ptr(res_len);
     if (snappy::RawUncompress(&source, ptr.c_str())) {