Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #4009 > unrolled thread

Self:Variable vs parameter

Started byMartin <spam@spam.spam>
First post2012-08-29 15:46 +0100
Last post2012-08-29 15:39 +0000
Articles 4 — 2 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Self:Variable vs parameter Martin <spam@spam.spam> - 2012-08-29 15:46 +0100
    Re: Self:Variable vs parameter "Wolfgang Riedmann" <wriedmann@gmail.com> - 2012-08-29 15:21 +0000
      Re: Self:Variable vs parameter Martin <spam@spam.spam> - 2012-08-29 16:35 +0100
        Re: Self:Variable vs parameter "Wolfgang Riedmann" <wriedmann@gmail.com> - 2012-08-29 15:39 +0000

#4009 — Self:Variable vs parameter

FromMartin <spam@spam.spam>
Date2012-08-29 15:46 +0100
SubjectSelf:Variable vs parameter
Message-ID<DXp%r.303855$Re2.178310@fx06.am4>
Just curious as to the answer.

Which is better for performance?

Using Self:something in a class or sending something as a parameter into 
each method?

Thanks

Martin

[toc] | [next] | [standalone]


#4011

From"Wolfgang Riedmann" <wriedmann@gmail.com>
Date2012-08-29 15:21 +0000
Message-ID<aa6qblFabuU1@mid.individual.net>
In reply to#4009
Hi Martin,

> Which is better for performance?
> 
> Using Self:something in a class or sending something as a parameter
> into each method?


If your code is:

oObject:SomeThing := oSomeThing
oObject:ExecuteMethod()

the following may be have a slightly bit better performance 

oObject:ExecuteMethod( oSomething )

but only if ExecuteMethod is strong typed.
If ExecuteMethod() cannot be strong typed, you should assign oSomething
to a local typed variable as first thing, so the compiler can generate
better code.

If you need the same Something object more times, then an assign to an
instance variable (export or protect) is better because every parameter
passing requires time.


HTH

Wolfgang

[toc] | [prev] | [next] | [standalone]


#4012

FromMartin <spam@spam.spam>
Date2012-08-29 16:35 +0100
Message-ID<7Gq%r.219199$mc1.59064@fx12.am4>
In reply to#4011
It is the order number within a hefty piece of code and can get called a 
few hundred times in class, I could use cOrder AS STRING as a parameter, 
or Self:cOrder within the code.

Currently using as a parameter but I am looking for the most efficient 
way of calling it.

On 29/08/2012 16:21, Wolfgang Riedmann wrote:
> Hi Martin,
>
>> Which is better for performance?
>>
>> Using Self:something in a class or sending something as a parameter
>> into each method?
>
>
> If your code is:
>
> oObject:SomeThing := oSomeThing
> oObject:ExecuteMethod()
>
> the following may be have a slightly bit better performance
>
> oObject:ExecuteMethod( oSomething )
>
> but only if ExecuteMethod is strong typed.
> If ExecuteMethod() cannot be strong typed, you should assign oSomething
> to a local typed variable as first thing, so the compiler can generate
> better code.
>
> If you need the same Something object more times, then an assign to an
> instance variable (export or protect) is better because every parameter
> passing requires time.
>
>
> HTH
>
> Wolfgang
>

[toc] | [prev] | [next] | [standalone]


#4013

From"Wolfgang Riedmann" <wriedmann@gmail.com>
Date2012-08-29 15:39 +0000
Message-ID<aa6rebFi44U1@mid.individual.net>
In reply to#4012
Hi Martin,

> It is the order number within a hefty piece of code and can get
> called a few hundred times in class, I could use cOrder AS STRING as
> a parameter, or Self:cOrder within the code.
> 
> Currently using as a parameter but I am looking for the most
> efficient way of calling it.

then obviously passing it as instance variable to the class and the
calling the method without parameters is more efficient because you
have only one parameter passing instead of more.


Wolfgang

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web