Skip to content

Improve loading optional dependencies#139

Closed
ppisar wants to merge 2 commits intoPhilterPaper:masterfrom
ppisar:optdeps
Closed

Improve loading optional dependencies#139
ppisar wants to merge 2 commits intoPhilterPaper:masterfrom
ppisar:optdeps

Conversation

@ppisar
Copy link
Contributor

@ppisar ppisar commented Nov 5, 2020

This patch set improves loading the optional dependencies for PNG and TIFF images.

A code in LA_*() methods was identical to a check is image_()
methods. This patch removes the in-lined code and calls the methods
instead.
The old code first probed for a dependency (e.g. Graphics::TIFF) and
then did not use it if the dependency was explicitly disabled (e.g.
-nouseGT).

This patch reverses the order to speed up the code and alleviate from
loading unused modules.
@PhilterPaper
Copy link
Owner

Is the intent here to replace the hard-coded eval check with a call to the LA_* (Library Available) calls? Your new code behaves a little differently than the old code, returning -1 if "don't use the library" regardless of whether it's installed, instead of 0 if it's not installed. I will have to look at the usage and see whether this makes any difference.

@ppisar
Copy link
Contributor Author

ppisar commented Nov 5, 2020 via email

@PhilterPaper
Copy link
Owner

Which piece of code does return -1?

The segments you changed in Builder.pm set the library usage flag to -1 if the library is available but you choose not to use it, 0 if it's unavailable, or 1 if it's available and you choose to use it. Your change sets it to -1 even if the library is UNavailable.

@ppisar
Copy link
Contributor Author

ppisar commented Nov 6, 2020 via email

@PhilterPaper
Copy link
Owner

PhilterPaper commented Nov 7, 2020

You're misreading the comment and the original code. You see the message (once) if 1) $rc==0 (no library available) and 2) not silenced with -silent. If $rc==-1 (library available but not wanted), you will not see the message. And of course, if $rc==1 (library available and being used), you will not see the message.

If you feel that the existing comments and documentation are unclear, please list the problem(s) that I could try to do something about.

@PhilterPaper
Copy link
Owner

OK, a bit of a compromise here. I now use $self->LA_* to get the initial $rc 0 or 1 setting (saves about 8 lines of code), but leave the rest of the code unchanged, so I'm not merging this pull request. Thank you anyway for the suggestion to use the "LA_" functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants