I have noticed in Progress (11.4) that repeated string concatenation can be very slow. For example in the following code.
DEF VAR i AS INT NO-UNDO.
DEF VAR c AS LONGCHAR NO-UNDO.
DO i = 1 TO 1000000:
c = c + STRING(i MOD 10).
END.
From my experience in Java, I think the problem is that each time we are concatenating, we are copying c which is an O(n) operation, so the whole procedure is O(n^2). Java provides the StringBuilder
class to solve this problem.
Is my analysis of the problem correct? And if so, is there a solution?
This is a known issue - the following link also contains a work-around by buffering concatenations in character variables:
https://blog.abevoelker.com/introducing_bigcharacter/
Recognized by Progress and addressed in 11.7.2: