From 47b0cc08f7128e75149f4fe5902f1f247ecfd78c Mon Sep 17 00:00:00 2001 From: Devin Gibson Date: Fri, 6 Dec 2024 13:31:17 -0500 Subject: [PATCH] Apply suggestions from code review Co-authored-by: haiqi96 <14502009+haiqi96@users.noreply.github.com> --- components/core/src/clp/CheckpointReader.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/core/src/clp/CheckpointReader.cpp b/components/core/src/clp/CheckpointReader.cpp index f17b651aa..a93dcb50f 100644 --- a/components/core/src/clp/CheckpointReader.cpp +++ b/components/core/src/clp/CheckpointReader.cpp @@ -3,8 +3,8 @@ namespace clp { auto CheckpointReader::try_seek_from_begin(size_t pos) -> ErrorCode { m_cur_pos = pos > m_checkpoint ? m_checkpoint : pos; - auto rc = m_reader->try_seek_from_begin(m_cur_pos); - if (ErrorCode_Success != rc) { + if (auto const rc = m_reader->try_seek_from_begin(m_cur_pos); + ErrorCode_Success != rc) { return rc; } if (m_cur_pos >= m_checkpoint) { @@ -15,15 +15,15 @@ auto CheckpointReader::try_seek_from_begin(size_t pos) -> ErrorCode { auto CheckpointReader::try_read(char* buf, size_t num_bytes_to_read, size_t& num_bytes_read) -> ErrorCode { - if ((m_cur_pos + num_bytes_to_read) > m_checkpoint) { - num_bytes_to_read = m_checkpoint - m_cur_pos; - } - if (m_cur_pos == m_checkpoint) { return ErrorCode_EndOfFile; } + + if ((m_cur_pos + num_bytes_to_read) > m_checkpoint) { + num_bytes_to_read = m_checkpoint - m_cur_pos; + } - auto rc = m_reader->try_read(buf, num_bytes_to_read, num_bytes_read); + auto const rc = m_reader->try_read(buf, num_bytes_to_read, num_bytes_read); m_cur_pos += num_bytes_read; if (ErrorCode_EndOfFile == rc) { if (0 == num_bytes_read) {