susumu.yata
null+****@clear*****
Tue Dec 16 10:54:28 JST 2014
susumu.yata 2014-11-25 11:29:33 +0900 (Tue, 25 Nov 2014) New Revision: 7301cea9a401b0247eaf744f9253b597647a23e7 https://github.com/groonga/grnxx/commit/7301cea9a401b0247eaf744f9253b597647a23e7 Message: Rename Bool::value() to raw(). (#116) Modified files: include/grnxx/data_types/scalar/bool.hpp lib/grnxx/impl/sorter.cpp Modified: include/grnxx/data_types/scalar/bool.hpp (+23 -23) =================================================================== --- include/grnxx/data_types/scalar/bool.hpp 2014-11-25 11:25:00 +0900 (8967707) +++ include/grnxx/data_types/scalar/bool.hpp 2014-11-25 11:29:33 +0900 (9d1c81e) @@ -17,27 +17,27 @@ class Bool { Bool &operator=(const Bool &) & = default; explicit constexpr Bool(bool value) - : value_(value ? true_value() : false_value()) {} - explicit constexpr Bool(NA) : value_(na_value()) {} + : raw_(value ? raw_true() : raw_false()) {} + explicit constexpr Bool(NA) : raw_(raw_na()) {} - constexpr uint8_t value() const { - return value_; + constexpr uint8_t raw() const { + return raw_; } constexpr bool is_true() const { - return value_ == true_value(); + return raw_ == raw_true(); } constexpr bool is_false() const { - return value_ == false_value(); + return raw_ == raw_false(); } constexpr bool is_na() const { - return value_ == na_value(); + return raw_ == raw_na(); } // -- Unary operators -- constexpr Bool operator!() const { - return is_na() ? na() : Bool(static_cast<uint8_t>(value_ ^ true_value())); + return is_na() ? na() : Bool(static_cast<uint8_t>(raw_ ^ raw_true())); } constexpr Bool operator~() const { return operator!(); @@ -46,27 +46,27 @@ class Bool { // -- Binary operators -- constexpr Bool operator&(Bool rhs) const { - return Bool(static_cast<uint8_t>(value_ & rhs.value_)); + return Bool(static_cast<uint8_t>(raw_ & rhs.raw_)); } constexpr Bool operator|(Bool rhs) const { - return Bool(static_cast<uint8_t>(value_ | rhs.value_)); + return Bool(static_cast<uint8_t>(raw_ | rhs.raw_)); } constexpr Bool operator^(Bool rhs) const { return (is_na() || rhs.is_na()) ? na() : - Bool(static_cast<uint8_t>(value_ ^ rhs.value_)); + Bool(static_cast<uint8_t>(raw_ ^ rhs.raw_)); } Bool &operator&=(Bool rhs) & { - value_ &= rhs.value_; + raw_ &= rhs.raw_; return *this; } Bool &operator|=(Bool rhs) & { - value_ |= rhs.value_; + raw_ |= rhs.raw_; return *this; } Bool &operator^=(Bool rhs) & { if (!is_na()) { - value_ = rhs.is_na() ? na_value() : (value_ ^ rhs.value_); + raw_ = rhs.is_na() ? raw_na() : (raw_ ^ rhs.raw_); } return *this; } @@ -75,18 +75,18 @@ class Bool { constexpr Bool operator==(Bool rhs) const { return (is_na() || rhs.is_na()) ? na() : - Bool(static_cast<uint8_t>(value_ ^ rhs.value_ ^ true_value())); + Bool(static_cast<uint8_t>(raw_ ^ rhs.raw_ ^ raw_true())); } constexpr Bool operator!=(Bool rhs) const { return (is_na() || rhs.is_na()) ? na() : - Bool(static_cast<uint8_t>(value_ ^ rhs.value_)); + Bool(static_cast<uint8_t>(raw_ ^ rhs.raw_)); } constexpr bool match(Bool rhs) const { - return value_ == rhs.value_; + return raw_ == rhs.raw_; } constexpr bool unmatch(Bool rhs) const { - return value_ != rhs.value_; + return raw_ != rhs.raw_; } static constexpr DataType type() { @@ -97,20 +97,20 @@ class Bool { return Bool(NA()); } - static constexpr uint8_t true_value() { + static constexpr uint8_t raw_true() { return 0b11; } - static constexpr uint8_t false_value() { + static constexpr uint8_t raw_false() { return 0b00; } - static constexpr uint8_t na_value() { + static constexpr uint8_t raw_na() { return 0b01; } private: - uint8_t value_; + uint8_t raw_; - explicit constexpr Bool(uint8_t value) : value_(value) {} + explicit constexpr Bool(uint8_t raw) : raw_(raw) {} }; } // namespace grnxx Modified: lib/grnxx/impl/sorter.cpp (+4 -4) =================================================================== --- lib/grnxx/impl/sorter.cpp 2014-11-25 11:25:00 +0900 (6822519) +++ lib/grnxx/impl/sorter.cpp 2014-11-25 11:29:33 +0900 (4cc3355) @@ -57,14 +57,14 @@ class SeparatorNode : public TypedNode<Bool> { public: explicit SeparatorNode(SorterOrder &&order) : TypedNode<Bool>(std::move(order)), - prior_value_((order.type == SORTER_REGULAR_ORDER) ? - Bool::false_value() : Bool::true_value()) {} + prior_raw_((order.type == SORTER_REGULAR_ORDER) ? + Bool::raw_false() : Bool::raw_true()) {} ~SeparatorNode() = default; void sort(ArrayRef<Record> records, size_t begin, size_t end); private: - uint8_t prior_value_; + uint8_t prior_raw_; }; void SeparatorNode::sort(ArrayRef<Record> records, size_t begin, size_t end) { @@ -81,7 +81,7 @@ void SeparatorNode::sort(ArrayRef<Record> records, size_t begin, size_t end) { values_[i] = values_[na_offset - 1]; --na_offset; } else { - if (values_[i].value() == prior_value_) { + if (values_[i].raw() == prior_raw_) { std::swap(records[posterior_offset], records[i]); ++posterior_offset; } -------------- next part -------------- HTML����������������������������... Descargar