On Mon, May 21, 2012 at 5:28 PM, Albert York <alfromme@xxxxxxxxx> wrote:
Assuming there is a reason I have to clear the data before starting,
This is a big (and I would guess rather crazy) assumption. If you
happen to be able to describe a situation where this is the case, I
would be interested to hear it.
which is faster:
workfield = *blanks
or
%substr(workfield:1:len) = *blanks
Well, %substr doesn't work at all, but maybe you mean %subst. ;)
The answer is that on a model 810 running V5R2, blanking out a small
substring is faster than clearing the entire field of 2000 bytes,
potentially several times faster, if you are clearing only a tiny
portion of the field. I don't know the underlying low-level code, I
just wrote a simple-minded RPG program to try various things.
I cannot stress enough, though, that I don't know a legitimate use
case for explicitly pre-clearing a field. And I still recommend human
source readability over micro-optimization. (Otherwise, why aren't we
all programming in assembly? Or lower?)
If you do not explicitly pre-clear the field, you have the best of all
worlds - fastest (because no-op is faster than any op) and clearest
source code (zero lines of superfluous code is easier to write, read,
and maintain than some positive number of lines of superfluous code).
John
As an Amazon Associate we earn from qualifying purchases.