mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:18:12 +00:00
LibPDF: Tweak implementation of postscript roll
op
Since positive offsets roll to the right, it makes more sense to do the big reverse first. Gets rid of an awkward minus sign. No behavior change.
This commit is contained in:
parent
b23ed86889
commit
cd9f4655ec
1 changed files with 2 additions and 2 deletions
|
@ -728,7 +728,7 @@ PDFErrorOr<void> PostScriptCalculatorFunction::execute(Vector<Token> const& toke
|
|||
TRY(stack.pop());
|
||||
break;
|
||||
case OperatorType::Roll: {
|
||||
int j = -(int)TRY(stack.pop());
|
||||
int j = (int)TRY(stack.pop());
|
||||
int n = (int)TRY(stack.pop());
|
||||
if (n < 0)
|
||||
return Error { Error::Type::RenderingUnsupported, "PostScript roll with negative argument"_string };
|
||||
|
@ -742,9 +742,9 @@ PDFErrorOr<void> PostScriptCalculatorFunction::execute(Vector<Token> const& toke
|
|||
return Error { Error::Type::RenderingUnsupported, "PostScript roll with argument larger than stack"_string };
|
||||
// http://pointer-overloading.blogspot.com/2013/09/algorithms-rotating-one-dimensional.html
|
||||
auto elements = stack.stack.span().slice(stack.top - n, n);
|
||||
elements.reverse();
|
||||
elements.slice(0, j).reverse();
|
||||
elements.slice(j).reverse();
|
||||
elements.reverse();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue