diff --git a/hikyuu_cpp/hikyuu/Stock.cpp b/hikyuu_cpp/hikyuu/Stock.cpp index ec9338e8..370d2d31 100644 --- a/hikyuu_cpp/hikyuu/Stock.cpp +++ b/hikyuu_cpp/hikyuu/Stock.cpp @@ -158,12 +158,10 @@ Stock::Stock(const string& market, const string& code, const string& name, uint3 : m_data(make_shared(market, code, name, type, valid, startDate, lastDate, tick, tickValue, precision, minTradeNumber, maxTradeNumber)) {} -bool Stock::operator!=(const Stock& stock) const { - HKU_IF_RETURN(this == &stock, false); - HKU_IF_RETURN(m_data == stock.m_data, false); - HKU_IF_RETURN(!m_data || !stock.m_data, true); - HKU_IF_RETURN(m_data->m_code != stock.code() || m_data->m_market != stock.market(), true); - return false; +bool Stock::operator==(const Stock& stock) const { + return this == &stock || m_data == stock.m_data || + (m_data && stock.m_data && (m_data->m_code == stock.m_data->m_code) && + (m_data->m_market == stock.m_data->m_market)); } const string& Stock::market() const { diff --git a/hikyuu_cpp/hikyuu/Stock.h b/hikyuu_cpp/hikyuu/Stock.h index c7ef2999..7aeca433 100644 --- a/hikyuu_cpp/hikyuu/Stock.h +++ b/hikyuu_cpp/hikyuu/Stock.h @@ -233,14 +233,14 @@ private: }; struct HKU_API Stock::Data { - string m_market; // 所属的市场简称 - string m_code; // 证券代码 - string m_market_code; // 市场简称证券代码 - string m_name; // 证券名称 - uint32_t m_type; // 证券类型 - bool m_valid; // 当前证券是否有效 - Datetime m_startDate; // 证券起始日期 - Datetime m_lastDate; // 证券最后日期 + string m_market; // 所属的市场简称 + string m_code; // 证券代码 + string m_market_code; // 市场简称证券代码 + string m_name; // 证券名称 + uint32_t m_type; // 证券类型 + bool m_valid; // 当前证券是否有效 + Datetime m_startDate; // 证券起始日期 + Datetime m_lastDate; // 证券最后日期 StockWeightList m_weightList; // 权息信息列表 std::mutex m_weight_mutex; @@ -291,8 +291,8 @@ inline uint64_t Stock::id() const { return isNull() ? 0 : (int64_t)m_data.get(); } -inline bool Stock::operator==(const Stock& stock) const { - return (*this != stock) ? false : true; +inline bool Stock::operator!=(const Stock& stock) const { + return !(*this == stock); } } // namespace hku