From: Shuai Ding Date: Thu, 16 Aug 2012 22:00:15 +0000 (-0700) Subject: change shared_ptr<>* to raw pointer X-Git-Tag: v0.22.0~1201 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=51f060fec3b7da5ee9630d62e1f9c895fcbacccc;p=folly.git change shared_ptr<>* to raw pointer Summary: change shared_ptr<>* to raw pointer in forwardIndex in RTIndex. This saves 16 bytes per forward list (decrease from 88 to 72) and translates to about 4-5% memory saving for RTIndex in ff tier. Test Plan: unit test Reviewed By: xliux@fb.com FB internal diff: D551191 --- diff --git a/folly/ConcurrentSkipList.h b/folly/ConcurrentSkipList.h index c5223849..3299d75c 100644 --- a/folly/ConcurrentSkipList.h +++ b/folly/ConcurrentSkipList.h @@ -145,11 +145,11 @@ class ConcurrentSkipList { // being treated as a scalar in the compiler). static_assert(MAX_HEIGHT >= 2 && MAX_HEIGHT < 64, "MAX_HEIGHT can only be in the range of [2, 64)"); - typedef detail::SkipListNode NodeType; typedef std::unique_lock ScopedLocker; typedef ConcurrentSkipList SkipListType; public: + typedef detail::SkipListNode NodeType; typedef T value_type; typedef T key_type; @@ -170,6 +170,12 @@ class ConcurrentSkipList { return boost::shared_ptr(new SkipListType(height)); } + // create a unique_ptr skiplist object with initial head height. + static std::unique_ptr createRawInstance(int height=1) { + return std::unique_ptr(new SkipListType(height)); + } + + //=================================================================== // Below are implementation details. // Please see ConcurrentSkipList::Accessor for stdlib-like APIs.