Refactor numeric-editing formatting for speed.
Significant speedup for Cobol numeric-editing PICTURE string formatting.
The Cobol compiler’s routine for formatting numeric strings according to PICTURE clauses has been refactored for performance. A new specific routine for ASCII strings eliminates costly encoding conversions. The underlying conversion logic has also been optimized, resulting in an approximately eight-fold speed improvement for this operation. Changes include modifications in genapi.cc, move.cc, parse.y, symbols.cc, and util.cc, along with updates to libgcobol.
In Details
The cobol compiler frontend has undergone significant performance improvements in its numeric-editing (e.g., PICTURE clause formatting) capabilities. The core of the change involves factoring out a dedicated path for ASCII string handling, bypassing general-purpose encoding conversions. Furthermore, the internal algorithm for numeric-to-edited-string conversion has been redesigned, yielding an ~8x speedup. These changes affect various internal routines like mh_to_numeric_edited and cbl_field_t::encode_numeric.
- numeric-edited
- In COBOL, refers to data items defined with a
PICTUREclause that allows for formatted numeric output, including currency symbols, decimal points, and commas. - PICTURE string
- A clause in COBOL used to define the format and type of a data item, specifying characteristics like numeric, alphabetic, alphanumeric, and editing symbols for display.
- lang-specs.h
- A header file in GCC that defines language-specific specifications and options, often used to configure compiler behavior for particular languages.
- libgcobol
- The runtime library for the GNU Cobol compiler, providing essential functions for executing Cobol programs.