From 63e2a6c8782aa4b49af84687c52bef5d05cc15f1 Mon Sep 17 00:00:00 2001 From: magicpanda0618 Date: Tue, 1 Aug 2017 02:47:47 +0800 Subject: [PATCH] fix: bugs in StringIndex by chenjiaqi --- StringIndex/StringIndex.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/StringIndex/StringIndex.cpp b/StringIndex/StringIndex.cpp index ffe17a3..4da9756 100644 --- a/StringIndex/StringIndex.cpp +++ b/StringIndex/StringIndex.cpp @@ -108,6 +108,9 @@ void StringIndexFile::addRequest(unsigned id, std::string *str) void StringIndexFile::trySequenceAccess() { + if (this->request.empty()) + return; + long min_begin = -1, max_end = 0; for (int i = 0; i < (int)this->request.size(); i++) { @@ -156,6 +159,9 @@ void StringIndexFile::trySequenceAccess() long offset = this->request[pos].offset; long length = this->request[pos].length; + if (offset >= current_block_end) + break; + if (current_block_begin <= offset && offset + length <= current_block_end) { allocBuffer(length);