Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 19, 1997

In-Line Code

Calling a function or procedure incurs some overhead. If you have a two-line function that is called from only three places, you might consider putting those three lines in the functions themselves and not make them a function. This can save some processing time. This could lead to some future maintenance problems, however. Here are two options.
 Option 1: 

For iLoop = 1 To 100 
Call DoSomething(iLoop) 
Next 
Sub DoSomething(iLoop As Integer) 
Print iLoop + 10 
End Sub 

Option 2: 

For iLoop = 1 To 100 
Print iLoop + 10 
Next 
The two options are very simple examples, but you can see that if you use the statement Print iLoop + 10 in two or more places, you have a maintenance problem if you ever need to change that line. Option 2, however, will run faster than Option 1.
Paul D. Sheriff
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date