Mike Yearwood
Toronto, Ontario, Canada
Versions des environnements
Network:
Windows 2008 Server
>>>>That is another reason I always concatenate the comma without any conditional checks and then delete the one trailing comma afterward. Firing a conditional check for each loop is not efficient in the long run.
>>>>
>>>>for x = 1 to 10
>>>> lcString = m.lnString + "a" + ","
>>>>endfor
>>>>lcString = left(m.lcString,len(m.lcString)-1)
>>>
>>>The code that leaves the trailing comma is not mine. But I am sure I will find the places where I need to "clean up" and the problem will be resolved.
>>>Thank you
>>
>>I did not say it was. Just offering a single way to do this simple job. I often wonder why this cannot be done one way by everyone.
>
>because edge cases might lurk. Loops with uncertain (read: no unrolling in code) but very low loop count but very heavy len(m.lcString) at loop end come to mind. Or separation is not done with "," but char depending on circumstances, possibly more than a sinngle char.
Not so. This is a very simple thing I posted above. In such a simple case, the other cases would be handled differently. You'd need strings bigger than 100 chars before len would be slower and then for all the people who say m. is not important, the differences are not important enough to suggest that doing the conditional check in the loop is better most of the time.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement