GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
cobol Performance Win

cobol: Improve numeric-edited formatting speed by moving processing to compile time.

COBOL numeric-edited output formatting is faster by performing PICTURE clause processing at compile time instead of runtime.

The performance of converting numerical strings to numeric-edited variables in GCC’s COBOL compiler has been significantly improved. This optimization is achieved by moving the processing of PICTURE clauses, which define the format of edited numeric output, from runtime execution to compile time. This reduces the overhead during program execution by pre-calculating and embedding formatting information directly into the compiled code.

In Details

This change optimizes the cbl_field_t::encode_numeric function in GCC's COBOL compiler by shifting PICTURE clause interpretation from runtime to compile time. The expand_expanded routine, now used in symbols.cc and util.cc, pre-processes the PICTURE string at compile time, embedding the necessary formatting data. This eliminates the need for runtime interpretation of the PICTURE clause for each conversion, improving performance for numeric-edited fields. The changes affect genapi.cc, symbols.cc, symbols.h, util.cc, libgcobol.cc, and valconv.cc.

For Context
numeric-edited
A data type in COBOL that represents a number formatted for display according to a PICTURE clause. It includes elements like currency symbols, decimal points, and leading zeros.
PICTURE clause
A COBOL clause used to define the format and editing rules for a data item, particularly for numeric and edited numeric fields.
Filed Under: coboloptimizationperformance