Optimize reading of repeating level 3 packet data

This commit is contained in:
Dan Paulat 2022-01-08 21:48:56 -06:00
parent f1472275bc
commit bf56680d85
5 changed files with 80 additions and 81 deletions

View file

@ -105,28 +105,24 @@ bool UnlinkedVectorPacket::Parse(std::istream& is)
// The number of vectors is equal to the size divided by the number of bytes
// in a vector
int vectorCount = vectorSize / 8;
int16_t beginI;
int16_t beginJ;
int16_t endI;
int16_t endJ;
int vectorCount = vectorSize / 8;
p->beginI_.resize(vectorCount);
p->beginJ_.resize(vectorCount);
p->endI_.resize(vectorCount);
p->endJ_.resize(vectorCount);
for (int v = 0; v < vectorCount && !is.eof(); v++)
{
is.read(reinterpret_cast<char*>(&beginI), 2);
is.read(reinterpret_cast<char*>(&beginJ), 2);
is.read(reinterpret_cast<char*>(&endI), 2);
is.read(reinterpret_cast<char*>(&endJ), 2);
is.read(reinterpret_cast<char*>(&p->beginI_[v]), 2);
is.read(reinterpret_cast<char*>(&p->beginJ_[v]), 2);
is.read(reinterpret_cast<char*>(&p->endI_[v]), 2);
is.read(reinterpret_cast<char*>(&p->endJ_[v]), 2);
beginI = ntohs(beginI);
beginJ = ntohs(beginJ);
endI = ntohs(endI);
endJ = ntohs(endJ);
p->beginI_.push_back(beginI);
p->beginJ_.push_back(beginJ);
p->endI_.push_back(endI);
p->endJ_.push_back(endJ);
p->beginI_[v] = ntohs(p->beginI_[v]);
p->beginJ_[v] = ntohs(p->beginJ_[v]);
p->endI_[v] = ntohs(p->endI_[v]);
p->endJ_[v] = ntohs(p->endJ_[v]);
}
if (is.eof())