Bug 703246

Summary: Inefficient implementation of endbfchar
Product: Ghostscript Reporter: Peter Cherepanov <sphinx.pinastri>
Component: PS InterpreterAssignee: Peter Cherepanov <sphinx.pinastri>
Status: RESOLVED FIXED    
Severity: normal CC: ere.maijala
Priority: P4    
Version: master   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: Patch
Patch for endbfchar and endbfrange

Description Peter Cherepanov 2020-12-10 04:02:09 UTC
This is bug report for a new sample file, attached to a unrelated bug 702381 as the comment #8.

Ghostscript takes extremely long time to parse a CMap with 38917 entries in a single beginbfchar ... endbfchar range. This inefficiency is caused by repeated use of --roll-- on the whole data set, which results in quadratic complexity.

A simple rewrite of beginbfchar restores linear complexity and reduces parsing time to 1 sec. The function endbfrange has the same problem, but it is not changed, since it is not used by the sample file.
Comment 3 Ray Johnston 2021-03-24 04:13:02 UTC
Fixed in commit fd919a2ed. Thanks, Peter.