From: JINMEI Tatuya Date: Wed, 25 Jul 2012 17:26:21 +0000 (-0700) Subject: [2091b] simplified bitfield swap X-Git-Tag: trac2351_base~158^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=98181a847e71f8a502f5614158bf2ade6dd8fc5f;p=thirdparty%2Fkea.git [2091b] simplified bitfield swap --- diff --git a/src/lib/datasrc/rbtree.h b/src/lib/datasrc/rbtree.h index c1a672c76a..ab6523bb8c 100644 --- a/src/lib/datasrc/rbtree.h +++ b/src/lib/datasrc/rbtree.h @@ -1638,16 +1638,13 @@ RBTree::nodeFission(util::MemorySegment& mem_sgmt, RBNode& node, std::swap(node.data_, down_node->data_); - // Swap flags bitfields; yes, this is ugly. The right solution is to - // implement the above note regarding #2054, then we won't have to swap - // the flags in the first place. - struct { - uint32_t flags_ : 23; - uint32_t unused_ : 9; - } tmp; - tmp.flags_ = node.flags_; + // Swap flags bitfields; yes, this is ugly (it appears we cannot use + // std::swap for bitfields). The right solution is to implement + // the above note regarding #2054, then we won't have to swap the + // flags in the first place. + const uint32_t tmp = node.flags_; node.flags_ = down_node->flags_; - down_node->flags_ = tmp.flags_; + down_node->flags_ = tmp; down_node->down_ = node.getDown(); node.down_ = down_node;