You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Guillaume Maillrd <gu...@ilm-informatique.fr> on 2024/03/15 13:49:00 UTC

AFMParser optimization

Hi,

During a profiling session of my application, I found something that 
could interest you.

To speedup the AFMParser (50% gain),
the "equals" in parseCharMetric should be written in this order ( order 
of top 5 usage) :

if (nextCommand.equals(CHARMETRICS_C)) {
...
} else if (nextCommand.equals(CHARMETRICS_WX)) {
...
} else if (nextCommand.equals(CHARMETRICS_N)) {
...
} else if (nextCommand.equals(CHARMETRICS_B)) {
...
} else if (nextCommand.equals(CHARMETRICS_L)) {
...
} ...

On my setup, it removes 80k calls to "equals".

Regards,

Guillaume




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: AFMParser optimization

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

Thank you, done.

Tilman

On 15.03.2024 14:49, Guillaume Maillrd wrote:
> Hi,
>
> During a profiling session of my application, I found something that 
> could interest you.
>
> To speedup the AFMParser (50% gain),
> the "equals" in parseCharMetric should be written in this order ( 
> order of top 5 usage) :
>
> if (nextCommand.equals(CHARMETRICS_C)) {
> ...
> } else if (nextCommand.equals(CHARMETRICS_WX)) {
> ...
> } else if (nextCommand.equals(CHARMETRICS_N)) {
> ...
> } else if (nextCommand.equals(CHARMETRICS_B)) {
> ...
> } else if (nextCommand.equals(CHARMETRICS_L)) {
> ...
> } ...
>
> On my setup, it removes 80k calls to "equals".
>
> Regards,
>
> Guillaume
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org