Browse DevX
Sign up for e-mail newsletters from DevX

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



Building the Right Environment to Support AI, Machine Learning and Deep Learning

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) 
Sub DoSomething(iLoop As Integer) 
Print iLoop + 10 
End Sub 

Option 2: 

For iLoop = 1 To 100 
Print iLoop + 10 
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.



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