fix: bugs in StringIndex

by chenjiaqi
This commit is contained in:
magicpanda0618 2017-08-01 02:47:47 +08:00
parent aac9638541
commit 63e2a6c878
1 changed files with 6 additions and 0 deletions

View File

@ -108,6 +108,9 @@ void StringIndexFile::addRequest(unsigned id, std::string *str)
void StringIndexFile::trySequenceAccess() void StringIndexFile::trySequenceAccess()
{ {
if (this->request.empty())
return;
long min_begin = -1, max_end = 0; long min_begin = -1, max_end = 0;
for (int i = 0; i < (int)this->request.size(); i++) for (int i = 0; i < (int)this->request.size(); i++)
{ {
@ -156,6 +159,9 @@ void StringIndexFile::trySequenceAccess()
long offset = this->request[pos].offset; long offset = this->request[pos].offset;
long length = this->request[pos].length; long length = this->request[pos].length;
if (offset >= current_block_end)
break;
if (current_block_begin <= offset && offset + length <= current_block_end) if (current_block_begin <= offset && offset + length <= current_block_end)
{ {
allocBuffer(length); allocBuffer(length);