Enrico,

The modification is simple.

In strtran.c
After line 181 insert the instruction:
     return;

After line 201 (out of else) insert the instruction:
     hb_itemReturn( pText);

Delete all "else" from line 183 to 201

Note: Line numbers before any modification.

With this modification, when STRTRAN not modify the text, return the 
same item passed as parameter.

Code before:

-------------------------

                      hb_retclenAdopt( szResult, ulLength );
                   }
                   else
                   {
                      hb_retclen( szText, ulText );
                   }
                }
                else
                {
                   hb_retclen( szText, ulText );
                }
             }
             else
             {
                hb_retclen( szText, ulText );
             }
          }
          else
          {
             hb_retclen( szText, ulText );
          }
       }
       else
       {
          hb_errRT_BASE_SubstR( EG_ARG, 1126, NULL, "STRTRAN", 3, 
hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError( 3 ) ); /* NOTE: 
Undocumented but existing Clipper Run-time error [vszakats] */
       }
-------------------------


Code after:

-------------------------

                      hb_retclenAdopt( szResult, ulLength );
                      return;
                   }
                }
             }
          }
          hb_itemReturn( pText );
       }
       else
       {
          hb_errRT_BASE_SubstR( EG_ARG, 1126, NULL, "STRTRAN", 3, 
hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError( 3 ) ); /* NOTE: 
Undocumented but existing Clipper Run-time error [vszakats] */
       }
------------------

Walter Negro


El 11/06/2011 06:51 a.m., Enrico Maria Giordano escribió:
> Dear friends, look at the following sample:
>
> FUNCTION MAIN()
>
>      LOCAL cShort := SPACE( 100 )
>      LOCAL cLong  := SPACE( 1024 * 1024 )
>
>      LOCAL nSec
>
>      LOCAL i
>
>      nSec = SECONDS()
>
>      FOR i = 1 TO 200000
>          cShort = STRTRAN( cShort, "TEST", "ABCDEFG" )
>      NEXT
>
>      ? SECONDS() - nSec
>
>      nSec = SECONDS()
>
>      FOR i = 1 TO 200000
>          IF AT( "TEST", cShort )>  0
>              cShort = STRTRAN( cShort, "TEST", "ABCDEFG" )
>          ENDIF
>      NEXT
>
>      ? SECONDS() - nSec
>
>      nSec = SECONDS()
>
>      FOR i = 1 TO 1000
>          cLong = STRTRAN( cLong, "TEST", "ABCDEFG" )
>      NEXT
>
>      ? SECONDS() - nSec
>
>      nSec = SECONDS()
>
>      FOR i = 1 TO 1000
>          IF AT( "TEST", cLong )>  0
>              cLong = STRTRAN( cLong, "TEST", "ABCDEFG" )
>          ENDIF
>      NEXT
>
>      ? SECONDS() - nSec
>
>      INKEY( 0 )
>
>      RETURN NIL
>
> The results on my PC are:
>
>   0.33
>   0.16
> 10.86
>   3.38
>
> So I wonder if we can speedup StrTran() just add the AT() test inside
> StrTran() C level code.
>
> Let me know if it can be done and if it is a good idea.
>
> EMG
>
> --
> EMAG Software Homepage:     http://www.emagsoftware.it
> The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
> The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
> The EMG Music page:         http://www.emagsoftware.it/emgmusic
>
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> xHarbour-developers mailing list
> xHarbour-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/xharbour-developers
>
>



------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
xHarbour-developers mailing list
xHarbour-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xharbour-developers

Reply via email to