ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If I am copying the values from a function that returns a list value to a list of scalars, and I don't need all of the function's returns, do I gain any performance increase by assigning the unused values to undef? For example let's say I was using the localtime function, and all I wanted was the day, month, and year:
I looked over my post, and realized that would create a nine variable array -- probably not helpful. Any ideas how I should go about getting only those three values?
but, i don't think you'll gain much in speed or memory.
Remember, localtime is making a slow system call anyway - so whether it return 9 or 3 will be a drop in the bucket timewise.
As BB said, it's the overall fn elapsed time, not the num of returned values.
However, this sounds like 'premature optimization'.
If you really ALREADY have performance issues, a better (overall) algorithm will give you much larger gains.
You won't get anything out of fooling around with this stuff above.
Perhaps you could tell show us your code & mention where it seems slow?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.