Hi all, I have a method call in my class which reads a value from a file and returns it.I am using this in the same class like thisWhat I am thinking is to declare a variable like thisand use it like thisWhich one is a better approach? I think that whenever handler.receive(...) is executed getTimeOut() method is called which calls the getTimeOut(...) method of pasAdapter which I think makes more calls and effects the performance. Whereas if I declare a variable and use it in my code I don't think it effects the performance.
Can anyone please comment on this. Thank you in advance.
How long does getTimeout() take? How many times does it run? Unless it is a long time, the performance is negligible and you should go with what is clearer to read. I think that is not using it as a variable.
chaitanya karthikk wrote:I don't know how much time it takes. [...]
Then don't optimize it.
You should only try to optimize code after positively identifying a performance problem, usually by using a profiler. Anything else is just wild guessing. Without a profiler, you've no way to identify the code that will benefit most from optimization. You might easily spend several hours shaving off a few millisecond of runtime.