|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64687 - sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector
From: bbartmanboost_at_[hidden]
Date: 2010-08-08 18:14:00
Author: bbartman
Date: 2010-08-08 18:13:53 EDT (Sun, 08 Aug 2010)
New Revision: 64687
URL: http://svn.boost.org/trac/boost/changeset/64687
Log:
refactored some code to reduce the number of variables needed for a particular function
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp | 31 ++++++++++++++++---------------
1 files changed, 16 insertions(+), 15 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp 2010-08-08 18:13:53 EDT (Sun, 08 Aug 2010)
@@ -226,26 +226,27 @@
if(_mask._size == 2) {
storage_t to_be_stored = 0;
- std::size_t bits_in_first_mask = 8 - _mask._offset;
- std::cout << "bits_in_first_mask: " << bits_in_first_mask << std::endl;
- value_type first_mask = (~(~value_type(0) << bits_in_first_mask))
- << (width - bits_in_first_mask - 1);
- typedef unsigned long long ullt;
- std::cout << "first_mask: " << std::hex << ullt(first_mask) << std::endl;
- to_be_stored = storage_t((first_mask&x)>>(width - bits_in_first_mask - 1));
- std::cout << "to be stored: " << std::hex << ullt(to_be_stored) << std::endl;
+ std::size_t bits_in_mask = 8 - _mask._offset;
storage_ptr_t byte_ptr = _ptr;
+
+ // std::cout << "bits_in_first_mask: " << bits_in_first_mask << std::endl;
+ value_type mask = (~(~value_type(0) << bits_in_mask))
+ << (width - bits_in_mask - 1);
+
+ typedef unsigned long long ullt;
+ // std::cout << "first_mask: " << std::hex << ullt(first_mask) << std::endl;
+ to_be_stored = storage_t((mask&x)>>(width - bits_in_mask - 1));
+ // std::cout << "to be stored: " << std::hex << ullt(to_be_stored) << std::endl;
*byte_ptr = (*byte_ptr & ~_mask._first_byte) | to_be_stored;
++byte_ptr;
- std::size_t bits_in_mask = width - bits_in_first_mask;
- std::cout << "bits in second mask: " << bits_in_mask << std::endl;
- value_type second_mask = ~(~value_type(0) << bits_in_mask);
- std::cout << "second mask: " << std::hex << ullt(second_mask) << std::endl;
- to_be_stored = storage_t((second_mask & x) << _mask._last_shift);
- std::cout << "to be stored: " << std::hex << ullt(to_be_stored) << std::endl;
+ bits_in_mask = width - bits_in_mask;
+ // std::cout << "bits in second mask: " << bits_in_mask << std::endl;
+ mask = ~(~value_type(0) << bits_in_mask);
+ // std::cout << "second mask: " << std::hex << ullt(second_mask) << std::endl;
+ to_be_stored = storage_t((mask & x) << _mask._last_shift);
+ // std::cout << "to be stored: " << std::hex << ullt(to_be_stored) << std::endl;
*byte_ptr = (*byte_ptr & ~_mask._last_byte) | to_be_stored;
-
return *this;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk