Skip to content

Commit 70c9ef9

Browse files
committed
PDFBOX-4892: optimize code, as suggested by valerybokov
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1891448 13f79535-47bb-0310-9956-ffa450edef68
1 parent 64b59d4 commit 70c9ef9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,10 @@ protected void processICCBasedColorSpace(PDColorSpace colorSpace)
251251
// PDFBOX-2819: load ICC profile as a stream, not as a byte array because of java error
252252
iccp = ICC_Profile.getInstance(is);
253253
}
254-
PDColorSpace altpdcs = iccBased.getAlternateColorSpace();
255-
if (altpdcs != null)
254+
PDColorSpace alternateColorSpace = iccBased.getAlternateColorSpace();
255+
if (alternateColorSpace != null)
256256
{
257-
ColorSpaces altCsId = ColorSpaces.valueOf(altpdcs.getName());
257+
ColorSpaces altCsId = ColorSpaces.valueOf(alternateColorSpace.getName());
258258
if (altCsId == ColorSpaces.Pattern)
259259
{
260260
context.addValidationError(new ValidationError(
@@ -280,7 +280,7 @@ protected void processICCBasedColorSpace(PDColorSpace colorSpace)
280280
{
281281
return;
282282
}
283-
validateICCProfileAlternateEntry(iccBased);
283+
validateICCProfileAlternateEntry(iccBased, alternateColorSpace);
284284
}
285285
}
286286
catch (IllegalArgumentException | ArrayIndexOutOfBoundsException e)
@@ -543,16 +543,16 @@ private boolean validateICCProfileNEntry(COSStream stream, ICC_Profile iccp)
543543
return true;
544544
}
545545

546-
private void validateICCProfileAlternateEntry(PDICCBased iccBased) throws IOException
546+
private void validateICCProfileAlternateEntry(
547+
PDICCBased iccBased, PDColorSpace alternateColorSpace) throws IOException
547548
{
548-
PDColorSpace altCS = iccBased.getAlternateColorSpace();
549-
if (altCS != null && altCS.getNumberOfComponents() != iccBased.getNumberOfComponents())
549+
if (alternateColorSpace.getNumberOfComponents() != iccBased.getNumberOfComponents())
550550
{
551551
// https://github.com/veraPDF/veraPDF-library/issues/773
552552
context.addValidationError(new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_INVALID_ENTRY,
553553
"/N entry of ICC profile is different (" + iccBased.getNumberOfComponents()
554554
+ ") than alternate entry colorspace component count ("
555-
+ altCS.getNumberOfComponents() + ")"));
555+
+ alternateColorSpace.getNumberOfComponents() + ")"));
556556
}
557557
}
558558
}

0 commit comments

Comments
 (0)