summaryrefslogtreecommitdiff
path: root/src/include/intpack.i
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@wiredtiger.com>2011-07-14 13:28:47 -0400
committerKeith Bostic <keith.bostic@wiredtiger.com>2011-07-14 13:28:47 -0400
commit03947f5c22713138c1bf80f58fa438350d420bd4 (patch)
treeda35b681376cc5999041851da4abcc322b2eebf4 /src/include/intpack.i
parentb66cef61bc30730e6a0351f173ce5541af5b34e9 (diff)
downloadmongo-03947f5c22713138c1bf80f58fa438350d420bd4.tar.gz
Replace N different cell extraction functions with a single cell_unpack
function. Since the cell likely points onto the on-disk page, each request for a cell field is likely to miss in the cache, it's better to do it all at once. Leave a cell-type function for the few cases where all I care about is the cell's type. --HG-- extra : rebase_source : 2e68f650381035f9ee55e18c4c90a389d11230d0
Diffstat (limited to 'src/include/intpack.i')
-rw-r--r--src/include/intpack.i31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/include/intpack.i b/src/include/intpack.i
index 5ffc6dfb694..8289fa21443 100644
--- a/src/include/intpack.i
+++ b/src/include/intpack.i
@@ -360,3 +360,34 @@ __wt_vsize_int(int64_t x)
/* For non-negative values, use the unsigned code above. */
return (__wt_vsize_uint((uint64_t)x));
}
+
+/*
+ * __wt_vpack_uint_len --
+ * Returns the length of the variable-length unsigned integer.
+ */
+static inline int
+__wt_vpack_uint_len(const uint8_t *p, u_int *lenp)
+{
+ /*
+ * This routine is used by the verification code to ensure it never
+ * oversteps the buffer because of corruption.
+ */
+ switch (*p & 0xf0) {
+ case POS_1BYTE_MARKER:
+ case POS_1BYTE_MARKER | 0x10:
+ case POS_1BYTE_MARKER | 0x20:
+ case POS_1BYTE_MARKER | 0x30:
+ *lenp = 1;
+ break;
+ case POS_2BYTE_MARKER:
+ case POS_2BYTE_MARKER | 0x10:
+ *lenp = 2;
+ break;
+ case POS_MULTI_MARKER:
+ *lenp = *p & 0xf;
+ break;
+ default:
+ return (WT_ERROR);
+ }
+ return (0);
+}