Dear MVP - Web control performance enquiries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear MVP,

A small question to you all
Lets say I have an application which gets the value from a drop down list,
e.g.

GetProductInfo1(ddl.selectedItem.value)
GetProductInfo2(ddl.selectedItem.value)
GetProductInfo3(ddl.selectedItem.value)
GetProductInfo4(ddl.selectedItem.value)
GetProductInfo5(ddl.selectedItem.value)

If you notice, I’m repeating ddl.selectedItem.value 5 times, would it be
better if I just put it into a variable e.g.

Dim int as integer

Int = ddl.selectedItem.value

And from there I just use the variable when ever I need it, rather then
having it call this stmt ddl.selectedItem.value. would it improve performance?

Thanks for taking the time to read this post.
 
It might make a relatively small performance gain. Chances are
GetProductInfo* will take orders of magnitude longer than the time
difference between your two code samples, particularly if the method
goes to the database.

I'd still pick the second option for readability - I think it will
make the code easier to read and maintain, but that is just a personal
preference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top