Skip to Main Content
IBM Z Software


This portal is to open public enhancement requests against IBM Z Software products. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).


Shape the future of IBM!

We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:

Search existing ideas

Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,

Post your ideas
  1. Post an idea.

  2. Get feedback from the IBM team and other customers to refine your idea.

  3. Follow the idea through the IBM Ideas process.


Specific links you will want to bookmark for future use

Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.

IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.

ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.

Status Under review
Workspace COBOL Compilers
Categories z/OS
Created by Guest
Created on Jan 23, 2026

IBM Enterprise COBOL V6+ - Improving the performance of the TRIM intrinsic function

Hi,

IBM Enterprise COBOL for z/OS version V6R2 introduced the TRIM intrinsic function for removing leading and trailing spaces from a string.


Before that, for our purposes, we developed a routine to find the useful length of a string based on the last non-space character in the string ; for example, to manage Db2 host variables for VARCHAR or LOB types.

This routine could be replaced by the following construct:

compute useful-length = function length(function trim(string TRAILING))


It turns out that the use of the TRIM function is 3 to 4 times more CPU-intensive than our old routine.

Our routine is based on a dichotomous search for the position of the string from which there are only spaces.

This of course depends on the size of the string (which can be known at compile time or at run time), and the actual position of the last non-space character in that string.

Note: Searching for the first non-whitespace character using an inline PERFORM VARYING instruction starting from the end gives a result substantially equivalent to searching using the intrinsic TRIM TRAILING function.

We propose modifying the binary code of the TRIM intrinsic function to improve performance:

  • Below a certain string size, apply the current algorithm, which searches for the first non-space character from the end;

  • Above this string size, apply the binary search method;

  • The critical string size will be determined through testing on different string lengths.


Comparison of the performance of the 3 algorithms for 100,000 search loops in a 6,000-character string with a useful length of 24 characters:

  • Calculation using intrinsic functions LENGTH and TRIM TRAILING: 0.2476 seconds

  • Calculation using binary search: 0.0595 seconds

  • Calculation using PERFORM VARYING: 0.2821 seconds


The tests were performed using IBM Enterprise COBOL for z/OS version 6.5.0 P250507 / ARCH(14).

Further tests performed with IBM Enterprise COBOL for z/OS version 6.4.0 P251031 / ARCH(14) show a significant performance degradation with the "PERFORM VARYING" algorithm :

  • Calculation using intrinsic functions LENGTH and TRIM TRAILING: 0.2527 seconds

  • Calculation using binary search: 0.0596 seconds

  • Calculation using PERFORM VARYING: 1.5615 seconds

Thanks.


Idea priority Medium
  • Admin
    Basil Kanneth
    Feb 4, 2026

    This idea is being investigated further.