diff --git a/src/observer/storage/clog/clog.cpp b/src/observer/storage/clog/clog.cpp index 7912cb699..1b8cd3b70 100644 --- a/src/observer/storage/clog/clog.cpp +++ b/src/observer/storage/clog/clog.cpp @@ -83,7 +83,7 @@ string CLogRecordData::to_string() const //////////////////////////////////////////////////////////////////////////////// -int _align8(int size) { return size / 8 * 8 + ((size % 8 == 0) ? 0 : 8); } +int _align8(int size) { return (size + 7) & ~7; } CLogRecord *CLogRecord::build_mtr_record(CLogType type, int32_t trx_id) { diff --git a/src/observer/storage/record/record_manager.cpp b/src/observer/storage/record/record_manager.cpp index 691d5e50f..a1f01a042 100644 --- a/src/observer/storage/record/record_manager.cpp +++ b/src/observer/storage/record/record_manager.cpp @@ -27,7 +27,7 @@ static constexpr int PAGE_HEADER_SIZE = (sizeof(PageHeader)); * * @param size 待对齐的字节数 */ -int align8(int size) { return (size + 7) / 8 * 8; } +int align8(int size) { return (size + 7) & ~7; } /** * @brief 计算指定大小的页面,可以容纳多少个记录