|
Rick, I found that I could build a faster routine, but the difference is trivial in most business applications that are generally governed by I/O performance. In the routine you posted, the output variable gets completely replace several times. walking through the input string and building the output piece by piece seems to be more efficient. Here is the routine I converted to use the %replace bif: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/iseries-toolkit/CVSROOT/src/qrpglesrc/replace.irp?rev=HEAD&content-type=text/vnd.viewcvs-markup I replaced that code with this: C EVAL Pos = %SCAN(InpSch :InpStr) C EVAL OutStr = InpStr C* Replace characters until no more found or at end of string C DOW Pos <> *ZERO C EVAL OutStr = %REPLACE( C InpRpl: C OutStr: C Pos: C %LEN(InpSch)) C EVAL Pos = Pos + %LEN(InpRpl) C* Enough left to search C IF Pos + %LEN(InpSch) - 1 <= %LEN(InpStr) C EVAL Pos = %SCAN(InpSch :OutStr :Pos) C ELSE C EVAL Pos = *ZERO C ENDIF C ENDDO My test over 500,000 records ran about 2% faster with the first version. Some of that difference depends on how many replacements are made in a given string. David Morris >>> rbaird@esourceconsulting.com 01/22/02 12:43PM >>> Which brings up a question. do using nested bifs give us a performance hit? ie. %trim() inside of %scan(), inside of %replace(). just string handling bifs? what about other bifs? inquiring minds do! ---my original message--- D fld s 30 inz('frank n furter') C dow %scan(' ':%trim(fld)) > 0 C eval fld = %replace(' ':%trim(fld): C %scan(' ':%trim(fld)):2) C enddo fld now equals 'frank n furter ' Rick
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.