|
Bob Cozzi wrote: > %trimR is expensive? I though only %trim was expensive. > Since you wrote %TRIMx why don't you make them work faster! :) > Also, another argument for an INLINE keyword as the overhead of using a > procedure call far outweighs using %TRIMR in that procedure. Well, the statement in question is "Eval InString=%Trimr(InString)". First, is %TRIMR expensive? %TRIMR is implemented by a loop that searches backwards through the string character by character until a non-blank is found. Well, that's not too bad, unless you have a lot of trailing blanks. Second, is string assignment expensive? Well, in this case, you're copying character by character from the expression to the target for the length of the source string. But if you're trimming the right-most blanks from a varying length character variable, there's a faster way to do it: eval %len(string) = %checkr(' ':string); In this case, you're searching for the right-most non-blank, and assigning the position of that character to the length of the character varying string. If the entire string is blank, then %CHECKR returns 0, and the length of the string is set to 0. Sure, %CHECKR involves it's own loop through the string, but in this case, there's no assignment of possibly lots of characters to the assignment target. A quick test showed improvements from around 10% to 35%, with greater improvement as the number of trailing blanks increased. This suggests that %TRIMR may well be the bottleneck. (OK, the performance improvement isn't that great, and may not necessarily be worth it overall. I was just expecting bigger gains than that. Like I said, yesterday afternoon I was in a nitpicky mood!) Cheers! Hans
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.