Don't think we do
We all know that moving a char once is the best
Fabio said in message#
950945>A simple optimization is that of do the substituytion right to left,
>this is not the best possible, but it can reduce the k on O(k*n*n).
David responded
>That is no optimization at all it still ends up moving the exact same number of bytes as doing it left to right.
Arguement of Fabio : (simple)Right to left moves less chars than (simple) left to right
___________________________________________
>Fabio and Gregory,
>
>I think you miss the point of david here. His algortithm is only moving the characters that are in the result and they're moved only once. His algorithm is (more or less) equivalent to the following VFP code
>
>
FUNCTION DeQoute (cString)
>LOCAL nPointer
>
>nPointer = 0
>FOR nT = 1 TO LEN(cString)
> cChar = SUBSTR(cString, nT, 1)
> IF cChar != '"'
> nPointer = nPointer + 1
> cString = STUFF(cString, nPointer, 1, cChar)
> ENDIF
>ENDFOR
>
>cString = SUBSTR(cString,1, nPointer)
>RETURN LEN(cString)
>
>Each character is only handled once. Honestly I really don't see any advantage to approach this problem from a right to left strategy here.
>
>The difference with the current implementation of CHRTRAN is that when a iterating through the characters in the string, it is going to move all remaining characters 1 position back whenever a character needs to be deleted. This results in the performance issue posibly a huge number of characters have moved multiple times in one CHARTRAN call. This is certainly not the case in davids algorithm.
>
>Walter,
Gregory