Skip to content

Commit 60e7771

Browse files
committed
fix: cache line alignment
1 parent 3b738d5 commit 60e7771

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/ui/trade_box.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,16 @@ void TradeBox::on_trade(const FIX44::MarketDataIncrementalRefresh& msg) {
252252
group.getField(side_field);
253253
side = binance::Side::from_str(side_field.getValue());
254254

255-
std::array<char, 16> tm_arr = {};
255+
constexpr size_t TIME_STRLEN = 16;
256+
std::array<char, TIME_STRLEN> tm_arr{};
256257
if (group.isSetField(FIX::FIELD::TransactTime)) {
257258
group.getField(e_time);
258259
FIX::UtcTimeStamp tval = e_time.getValue();
259-
int microseconds = tval.getMillisecond() * 1000 + tval.getMicroecond();
260-
std::snprintf(tm_arr.data(), tm_arr.size(), "%02d:%02d:%02d.%06d",
261-
tval.getHour(), tval.getMinute(), tval.getSecond(),
262-
microseconds);
260+
std::snprintf(tm_arr.data(), tm_arr.size(), "%02u:%02u:%02u.%06u",
261+
std::min<unsigned>(tval.getHour(), 23),
262+
std::min<unsigned>(tval.getMinute(), 59),
263+
std::min<unsigned>(tval.getSecond(), 59),
264+
std::min<unsigned>(tval.getMicroecond(), 999999));
263265
}
264266

265267
trade_ring_.push_back(core::Trade(price, size, trade_id_uint, side, tm_arr));

0 commit comments

Comments
 (0)