devxlogo

In-Line Code

In-Line Code

Calling a function or procedure incurs some overhead. If you have atwo-line function that is called from only three places, you might considerputting those three lines in the functions themselves and not make thema function. This can save some processing time. This could lead to somefuture 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 thatif you use the statement Print iLoop + 10 in two or more places, you havea maintenance problem if you ever need to change that line. Option 2, however,will run faster than Option 1.

devx-admin

Share the Post: