mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-22 16:05:56 +02:00
Slightly shorten some code in the src/core/function.js file
This commit is contained in:
parent
17a4d2e123
commit
8ced999803
@ -91,12 +91,10 @@ function toNumberArray(arr) {
|
|||||||
|
|
||||||
class PDFFunction {
|
class PDFFunction {
|
||||||
static getSampleArray(size, outputSize, bps, stream) {
|
static getSampleArray(size, outputSize, bps, stream) {
|
||||||
let i, ii;
|
let length = outputSize;
|
||||||
let length = 1;
|
for (const s of size) {
|
||||||
for (i = 0, ii = size.length; i < ii; i++) {
|
length *= s;
|
||||||
length *= size[i];
|
|
||||||
}
|
}
|
||||||
length *= outputSize;
|
|
||||||
|
|
||||||
const array = new Array(length);
|
const array = new Array(length);
|
||||||
let codeSize = 0;
|
let codeSize = 0;
|
||||||
@ -106,7 +104,7 @@ class PDFFunction {
|
|||||||
|
|
||||||
const strBytes = stream.getBytes((length * bps + 7) / 8);
|
const strBytes = stream.getBytes((length * bps + 7) / 8);
|
||||||
let strIdx = 0;
|
let strIdx = 0;
|
||||||
for (i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
while (codeSize < bps) {
|
while (codeSize < bps) {
|
||||||
codeBuf <<= 8;
|
codeBuf <<= 8;
|
||||||
codeBuf |= strBytes[strIdx++];
|
codeBuf |= strBytes[strIdx++];
|
||||||
@ -330,14 +328,8 @@ class PDFFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// encode value into domain of function
|
// encode value into domain of function
|
||||||
let dmin = domain[0];
|
const dmin = i > 0 ? bounds[i - 1] : domain[0];
|
||||||
if (i > 0) {
|
const dmax = i < length ? bounds[i] : domain[1];
|
||||||
dmin = bounds[i - 1];
|
|
||||||
}
|
|
||||||
let dmax = domain[1];
|
|
||||||
if (i < bounds.length) {
|
|
||||||
dmax = bounds[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
const rmin = encode[2 * i];
|
const rmin = encode[2 * i];
|
||||||
const rmax = encode[2 * i + 1];
|
const rmax = encode[2 * i + 1];
|
||||||
@ -414,17 +406,11 @@ class PDFFunction {
|
|||||||
const stack = evaluator.execute(input);
|
const stack = evaluator.execute(input);
|
||||||
const stackIndex = stack.length - numOutputs;
|
const stackIndex = stack.length - numOutputs;
|
||||||
for (i = 0; i < numOutputs; i++) {
|
for (i = 0; i < numOutputs; i++) {
|
||||||
value = stack[stackIndex + i];
|
output[i] = MathClamp(
|
||||||
let bound = range[i * 2];
|
stack[stackIndex + i],
|
||||||
if (value < bound) {
|
range[i * 2],
|
||||||
value = bound;
|
range[i * 2 + 1]
|
||||||
} else {
|
);
|
||||||
bound = range[i * 2 + 1];
|
|
||||||
if (value > bound) {
|
|
||||||
value = bound;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
output[i] = value;
|
|
||||||
}
|
}
|
||||||
if (cache_available > 0) {
|
if (cache_available > 0) {
|
||||||
cache_available--;
|
cache_available--;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user