This seems even more optimized:
---
FUNCTION MemoToArray( s )
LOCAL aLine := hb_ATokens( StrTran( RTrim( s ), CRLF, _EOL ), _EOL )
LOCAL nNewSize := 0
LOCAL line
FOR EACH line IN aLine DESCEND
IF ! Empty( line )
nNewSize := line:__enumIndex()
EXIT
ENDIF
NEXT
ASize( aLine, nNewSize )
RETURN aLine
---
Brgds,
Viktor
On 2009 Dec 6, at 14:18, Xavi wrote:
> Manu,
>
> Google traduce fácil y aceptablemente: al menos eso creo. :)
> http://translate.google.com/?hl=es#es|en
>
> "
> Hello Pritpal, I see that you use a lot len(a) inside the loops and is
> evaluation at each iteration.
> For example MemoToArray would be more optimized as follows:
> "
>
> Un saludo
> Xavi
>
> Manu escribió:
>> Hola Pritpal veo que usas mucho len( a ) dentro de los bucles y eso se
>> evalua en cada iteración.
>> Por ejemplo MemoToArray quedaría más optimizada así:
>> FUNCTION MemoToArray( s )
>> LOCAL a_, b_, i, j, n
>> s := trim( s )
>> s := strtran( s, CRLF, _EOL )
>> a_:= hb_atokens( s, _EOL )
>> n := len( a_ ) // <----------------------
>> FOR i := n TO 1 step -1
>> IF !empty( a_[ i ] )
>> EXIT
>> ENDIF
>> NEXT
>> IF i < n
>> b_ := Array( i ) // <----------------------
>> FOR j := 1 TO i
>> b_ := a_[ j ]
>> NEXT
>> ENDIF
>> RETURN b_
>
>
>
> _______________________________________________
> Harbour mailing list (attachment size limit: 40KB)
> [email protected]
> http://lists.harbour-project.org/mailman/listinfo/harbour
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour