mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-11-30 02:48:57 +08:00
优化 Stock 相等比较
This commit is contained in:
parent
2bbb700eb6
commit
2c23644593
@ -158,12 +158,10 @@ Stock::Stock(const string& market, const string& code, const string& name, uint3
|
||||
: m_data(make_shared<Data>(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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user