On Wed, Apr 22, 2020 at 8:48 AM Justin Taylor <JUSTIN@xxxxxxxxxxxxx> wrote:
I have a vague recollection that %str() is horribly inefficient, and its use is discourage. Am I remembering correctly, and is that still applicable to 7.3? If so, is there a preferred alternative?
I highly doubt %STR is discouraged. Indeed, I don't think any BIFs are
discouraged, per se. They each have a purpose, and when used for that
purpose, they are as good a solution for that purpose as any
alternative (and often better than any alternative).
I suspect what you are thinking of is the recommendation against
building long strings using fixed-length fields and %TRIM or %TRIMR.
If you have something like that going on, better to switch to using
varying-length fields instead.
The only other thing I can think of that might be tickling your memory
is that we, as humans, often work out pencil-and-paper numeric
operations in a "base-10 stringy" way, and we may be tempted to
recreate those on the computer by converting numbers to strings to do
the same thing. (Example off the top of my head: reverse the digits in
a number.) But it's usually faster for the computer to keep all its
operations in the machine-native numeric format and use math rather
than converting to and from string. (This is not a hard-and-fast rule;
it depends on the thing you're trying to do.)
John Y.
As an Amazon Associate we earn from qualifying purchases.