473,569 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inline or Precedure

I have Code that can either be run inline or called as multiple procedures. What would be the best practice, I like the component model with procedures but heard that inline executes faster... Thanks in advance...

Also, why does calling dispose such as with any var.dispose execute faster then simply setting to nothing.

Which is faster

dim me as va
some cod
me = nothin

o

dim me as va
some cod
me.dispos
me = nothin

Thanks...
Nov 20 '05 #1
4 976
in-line code always executes faster that external calls to methods. however,
you should *always* design applications for maintainability ...very few
occasions exist where that model of development will cost your application
time. w/o maintainability , you will *always* cost time...your customer's,
yours, and will eventually kill your app when it cost more to maintain than
the savings it originally afforded.

..net uses non-deterministic garbage collection in order to "know" when it
can release resources. setting an object to nothing in .net just helps the
gc better tell/determine that the object can no longer be reached/used...and
thereby can be killed off. disposing an object makes the gc look at that
object in a little different light...it has less to do in order to "know"
that no other referencing object can/has access to it.

hth,

steve
"Anthony Nystrom" <an************ @genetibase.com > wrote in message
news:0C******** *************** ***********@mic rosoft.com...
| I have Code that can either be run inline or called as multiple
procedures. What would be the best practice, I like the component model with
procedures but heard that inline executes faster... Thanks in advance...
|
| Also, why does calling dispose such as with any var.dispose execute faster
then simply setting to nothing..
|
| Which is faster:
|
| dim me as var
| some code
| me = nothing
|
| or
|
| dim me as var
| some code
| me.dispose
| me = nothing
|
| Thanks...
Nov 20 '05 #2
Hi Anthony,

Search this newsgroup than you will see that both that you use is called bad
code.
dim me as var
some code
me = nothing This you use when a property has to be reused by instance with a
databinding. When it is a value it makes no sence at all because it is only
set to its default value, so setting an integer to 0 or a string to "" does
the same and gives a better idea that you do that for reusing it.

dim me as var
some code
me.dispose This can only when there is a dispose method in a class and should than only
be used for unmanaged resources, however that is never for a value. me = nothing

See above.

I hope this helps something

Cor
Nov 20 '05 #3
Little addition in the sentence
This can only when there is a dispose method in a class and should than only be used for unmanaged resources, however that is never for a value.


(I placed later that unmanaged resource text in the middle)

now the end has to be.

A value has never a method, and therefore never a dispose.

Cor
Nov 20 '05 #4
* =?Utf-8?B?QW50aG9ueSB OeXN0cm9t?= <an************ @genetibase.com > scripsit:
I have Code that can either be run inline or called as multiple
procedures. What would be the best practice, I like the component model
with procedures but heard that inline executes faster... Thanks in
advance...

Also, why does calling dispose such as with any var.dispose execute faster then simply setting to nothing..

Which is faster:

dim me as var
some code
me = nothing

or

dim me as var
some code
me.dispose
me = nothing


IMO you should not need to care about that, the JITter is/will
be/should be able to do inlining automatically when it makes sense.

To your 2nd question: Setting an instance variable to 'Nothing' is
different from calling its 'Dispose' method. Calling 'Dispose' will
clean up unmanaged resources used by the instance at the time of calling
the procedure.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
6937
by: DJ WIce | last post by:
Hi all, I did make a script/css thing to replace the contextmenu on the website with a new one: http://www.djwice.com/contextmenu.html It works nice in MSIE, but on Netscape (and probable other browsers) it stays on the same place (does not "open'' where the mouse is). And the links do not work when you click on them. If anyone has...
14
2752
by: Chris Mantoulidis | last post by:
I am not clear with the use of the keyword inline... I believe you add it do a function when you implement the function inside the header file where the class is stored... But is that all? What am I missing? If that's all, then why did Bjarne even bother adding it to the language? If that's not all, what else can I do with "inline"?
47
3819
by: Richard Hayden | last post by:
Hi, I have the following code: /******************************** file1.c #include <iostream> extern void dummy(); inline int testfunc() {
20
3117
by: Grumble | last post by:
Hello everyone, As far as I understand, the 'inline' keyword is a hint for the compiler to consider the function in question as a candidate for inlining, yes? What happens when a function with extern linkage is inlined? Should the compiler still export the function? Or is an inlined function implicitly static?
7
2850
by: Srini | last post by:
Hello, Rules for inline functions say that they have to be defined in the same compilation unit as their declarations. For class member functions this means that the inline member functions must be defined either within the class or within the same header file. But its generally a good programming practice to have the declarations and...
6
3994
by: RainBow | last post by:
Greetings!! I introduced the so-called "thin-template" pattern for controlling the code bloat caused due to template usage. However, one of the functions in the template happens to be virtual as well. To support thin-template, I need to make virtual function as inline. Now, I know that compiler would generate an out-of-line copy when it
12
676
by: sam_cit | last post by:
Hi Everyone, I have few questions on inline functions, when i declare a function as inline, is it for sure that the compiler would replace the function call with the actual body of the function? or is it a call taken by compiler? Second, i see that it is same as what Macro's used to do for c, if so what is the advantage for going in for...
5
1914
by: Barry | last post by:
Hi, group First, I write same cases I've already known, I don't concern that specific compiler really do inline or not. Please check them if they are right, and add the cases I miss 1. // a.h inline void f() {}
2
1551
by: Barry | last post by:
Hi, group First, I write same cases I've already known, I don't concern that specific compiler really do inline or not. Please check them if they are right, and add the cases I miss 1. // a.h inline void f() {}
0
7697
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7968
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.