Rob Kennedy wrote:
You said that this is a performance issue. I don't know how you can say that when nobody has been shown any of the code (meaning you can't know what "this" refers to) and nobody has been told what the current performance of the unseen code is. You seem to have made a diagnosis without seeing any evidence.
I didn't see any code too. I just said that this is a performance issue. Depends on what you need to do, it's slower or quicker. I gave my general view about the topic.
PMyRec = ^TMyRec; TMyRec = record Id: Integer; Title: String[100]; end;
Let's think that you have a couple of data block to manage :
var
TestRec1, TestRec2: TMyRec;
begin
with TestRec1 do
begin
Id := 381;
Title := 'Rob';
end;// now you need both data block to have the same data
TestRec2 := TestRec1; // now they are same but 108 bytes data copied.. end;
We can do the same with pointers :
var
pTestRec1, pTestRec2: PMyRec;
begin
New(pTestRec1);
try
with pTestRec1^ do
begin
Id := 381;
Title := 'Rob';
end;
pTestRec2 := pTestRec1; // now they are the same and we just copied 4 bytes of data
finally
Dispose(pTestRec1);
end;
end;
This is a simple example which can show the advantage of using pointers. But i don't meant that we should use pointers everywhere. We should use when it brings an advantage to our existing problem.
Pointer is just a reference to a memory block. So, when they can bring some benefits to your application, you can decide to use them or not. You can still say that, i'll never used pointers in this way. Of course you don't have to use and this is your choice.. When all the object variables are the references to the objects, nobody can say that i had never used pointers before. Because all the objects you create in Delphi, returns a pointer by its type. This is why you cannot copy the Delphi objects in a natural way.
var
MyObject1, MyObject2: TMyObject;
begin
MyObject1 := TMyObject.Create;
..
MyObject1.SomeProperty := SomeValue;
..
MyObject2 := MyObject1; // could you copy the data from one location the the other one ? No, you just passed the MyObject2 pointer to the existing memory location which is created by MyObject1
..
MyObject1.SomeProperty := SomeDifferentValue;
if (MyObjet2.SomeProperty = MyObject1.SomeProperty) then
begin
// this line will run because they will have the same property values. Why ? Because they reference to the same place.
end;
end;
No, but you did seem to imply that using pointers is a guaranteed solution when performance is a problem.
If that's what you meant, then I disagree.
I didn't mean that. You know that too..
A demo of what, exactly?
I mean the demo of the code that you need to create for to see the performance differences. Which is for you to decide using pointers or not.
Hope you understand what i mean now,
Kind Regards,
Oktay Sancak
________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
_______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

