How to make this code short?
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Actually using strcat for that - it IS faster than some other methods which using format which is pretty slow.
Have you tried that theory in all situations? You couldn't have, that would take more time than the universe has (I assume the universe clock will face a 2038-type problem eventually and wrap around to negative time where it's life will begin again).

Sure, scanning one string for input and working on another for output will be incredibly slow most of the time. But with the simplicity of the format used in this case (it just has to check two characters and it knows what to do) and the fact that the function knows where the end of the string is and doesn't have to count it over time, it would mean that over longer strings with more concatenations the format should actually gain efficiency over repeated strcat's which have to count strings of longer and longer lengths repeatedly.

Just a theory but the logic makes sense. I won't go to great lengths to test it now but if I were to be faced with the possibility to use both in a particular situation where optimisation is a must, I would test both methods with my particular code instead of going with the popular belief unless I was certain that one way was better... Even then, who knows, it might just be that under the current circumstances, there is a surprising exception.
Reply


Messages In This Thread
How to make this code short? - by JaKe Elite - 03.10.2013, 10:17
Re: How to make this code short? - by Konstantinos - 03.10.2013, 10:19
Re: How to make this code short? - by Sublime - 03.10.2013, 10:21
Re: How to make this code short? - by JaKe Elite - 03.10.2013, 10:30
Re: How to make this code short? - by Konstantinos - 03.10.2013, 10:41
Re: How to make this code short? - by JaKe Elite - 03.10.2013, 10:54
Re: How to make this code short? - by xganyx - 03.10.2013, 11:10
Re: How to make this code short? - by Deji - 03.10.2013, 11:56
Re: How to make this code short? - by Konstantinos - 03.10.2013, 11:59
Re: How to make this code short? - by Deji - 03.10.2013, 13:29

Forum Jump:


Users browsing this thread: 2 Guest(s)