PDF-Writer
PDF-Writer copied to clipboard
'groupToShift' serves no purpose
In the following function 'groupToShift' serves no purpose as the data is not saved or used elsewhere
Byte* CharStringType2Interpreter::InterpretRoll(Byte* inProgramCounter)
{
EStatusCode status = mImplementationHelper->Type2Roll(mOperandStack);
if(status != PDFHummus::eSuccess)
return NULL;
CharStringOperand valueA;
CharStringOperand valueB;
valueB = mOperandStack.back();
mOperandStack.pop_back();
valueA = mOperandStack.back();
mOperandStack.pop_back();
long shiftAmount = (valueB.IsInteger ? valueB.IntegerValue : (long)valueB.RealValue);
long itemsCount = (valueA.IsInteger ? valueA.IntegerValue : (long)valueA.RealValue);
CharStringOperandList groupToShift;
for(long i=0; i < itemsCount;++i)
{
groupToShift.push_front(mOperandStack.back());
mOperandStack.pop_back();
}
if(shiftAmount > 0)
{
for(long j=0; j < shiftAmount;++j)
{
groupToShift.push_front(groupToShift.back());
groupToShift.pop_back();
}
}
else
{
for(long j=0; j < -shiftAmount;++j)
{
groupToShift.push_back(groupToShift.front());
groupToShift.pop_front();
}
}
for(long i=0; i < itemsCount;++i)
{
mOperandStack.push_back(mOperandStack.front());
mOperandStack.pop_front();
}
return inProgramCounter;
}
... besides it is better to use std::rotate rather than implement it as in
if (shiftAmount > 0)
std::rotate(groupToShift.begin(), groupToShift.end(), groupToShift.end() - shiftAmount);
else if (shiftAmount < 0)
std::rotate(groupToShift.begin(), groupToShift.end(), groupToShift.begin() - shiftAmount);
I stand corrected. list::iterator supports increment/decrement by one only. Besides the actual parameters are in the wrong order. Both minor fixes, if I could tell the purpose of the function.
Closed by mistake