MB-23994: Move StoredValue::setValue() to .cc 83/76783/6
authorDave Rigby <daver@couchbase.com>
Thu, 13 Apr 2017 17:13:43 +0000 (18:13 +0100)
committerManu Dhundi <manu@couchbase.com>
Fri, 21 Apr 2017 00:49:51 +0000 (00:49 +0000)
Refactoring in preparation for the actual code fix in next patch.

Change-Id: Id320ce729a1529f42c0ae3a6fbdedb69a84ad9d4
Reviewed-on: http://review.couchbase.org/76783
Reviewed-by: James Harrison <james.harrison@couchbase.com>
Reviewed-by: Manu Dhundi <manu@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
src/stored-value.cc
src/stored-value.h

index b1a70f8..ffcddb3 100644 (file)
@@ -28,6 +28,36 @@ const int64_t StoredValue::state_non_existent_key = -4;
 const int64_t StoredValue::state_temp_init = -5;
 const int64_t StoredValue::state_collection_open = -6;
 
+void StoredValue::setValue(const Item& itm, HashTable& ht) {
+    size_t currSize = size();
+    reduceCacheSize(ht, currSize);
+    value = itm.getValue();
+    deleted = itm.isDeleted();
+    flags = itm.getFlags();
+    datatype = itm.getDataType();
+    bySeqno = itm.getBySeqno();
+
+    cas = itm.getCas();
+    lock_expiry_or_delete_time = 0;
+    exptime = itm.getExptime();
+    revSeqno = itm.getRevSeqno();
+
+    nru = itm.getNRUValue();
+
+    if (isTempInitialItem()) {
+        markClean();
+    } else {
+        markDirty();
+    }
+
+    if (isTempItem()) {
+        markNotResident();
+    }
+
+    size_t newSize = size();
+    increaseCacheSize(ht, newSize);
+}
+
 bool StoredValue::ejectValue(HashTable &ht, item_eviction_policy_t policy) {
     if (eligibleForEviction(policy)) {
         reduceCacheSize(ht, value->length());
index 39ff590..c5ccdb4 100644 (file)
@@ -251,35 +251,7 @@ public:
      * @param itm the item with a new value
      * @param ht the hashtable that contains this StoredValue instance
      */
-    void setValue(const Item& itm, HashTable& ht) {
-        size_t currSize = size();
-        reduceCacheSize(ht, currSize);
-        value = itm.getValue();
-        deleted = itm.isDeleted();
-        flags = itm.getFlags();
-        datatype = itm.getDataType();
-        bySeqno = itm.getBySeqno();
-
-        cas = itm.getCas();
-        lock_expiry_or_delete_time = 0;
-        exptime = itm.getExptime();
-        revSeqno = itm.getRevSeqno();
-
-        nru = itm.getNRUValue();
-
-        if (isTempInitialItem()) {
-            markClean();
-        } else {
-            markDirty();
-        }
-
-        if (isTempItem()) {
-            markNotResident();
-        }
-
-        size_t newSize = size();
-        increaseCacheSize(ht, newSize);
-    }
+    void setValue(const Item& itm, HashTable& ht);
 
     void markDeleted() {
         deleted = true;