From 635ce51a6f514cc09a030b05feb39887745e1767 Mon Sep 17 00:00:00 2001 From: Georges Berenger Date: Thu, 19 Dec 2024 15:40:29 -0800 Subject: [PATCH] Simplify Summary: Avoid having two implementations to compute the size of a record. Differential Revision: D67464294 fbshipit-source-id: 33823371548e74631686465ed90275635530328a --- vrs/RecordFileReader.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/vrs/RecordFileReader.cpp b/vrs/RecordFileReader.cpp index 78a24991..6067d677 100644 --- a/vrs/RecordFileReader.cpp +++ b/vrs/RecordFileReader.cpp @@ -540,23 +540,12 @@ bool RecordFileReader::prefetchRecordSequence( !file_->isRemoteFileSystem()) { return false; // don't even try for local file systems! } - const vector& recordBoundaries = getRecordBoundaries(); - int64_t fileSize = file_->getTotalSize(); vector> segments; segments.reserve(records.size()); for (const IndexRecord::RecordInfo* record : records) { - int64_t recordOffset = record->fileOffset; - if (XR_VERIFY(recordOffset < fileSize)) { - auto nextBoundary = - upper_bound(recordBoundaries.begin(), recordBoundaries.end(), recordOffset); - if (XR_VERIFY(nextBoundary != recordBoundaries.end())) { - int64_t nextRecordOffset = *nextBoundary; - if (XR_VERIFY(nextRecordOffset > recordOffset)) { - segments.emplace_back( - static_cast(recordOffset), - static_cast(nextRecordOffset - recordOffset - 1)); - } - } + uint32_t recordSize = getRecordSize(record - recordIndex_.data()); + if (XR_VERIFY(recordSize > 0)) { + segments.emplace_back(static_cast(record->fileOffset), recordSize); } } return file_->prefetchReadSequence(segments, clearSequence);