Wilfried,

Perhaps I am missing something but I am not sure what it is you are trying 
to achieve with the "OR" version.  Are you wanting to SaveToFile for each 
individual account or for all of the accounts when something has 
changed?  If you are wanting to save ALL accounts whenever ONE of them then 
you don't need to change anything.  If, on the other hand, if you want to 
save each account as you encounter them being changed, you need to change 
to the suggested revised approach of cycling through 
CheckAccount(Items[n]); for each account and doing the SaveToFile for each 
one that has changed.

At 11/16/2005 10:38 AM +0100, you wrote:
>Hello,
>
>I have a strange optimization bug and I wonder wy, also I wonder if
>there are similar optimizations in Delphi that I need to know of. I
>explain with a peace of code:
>
>if Foo.CheckForChanges then
>   Foo.SaveToFile;
>
>procedure TFoo.CheckForChanges: boolean;
>var
>   n: integer;
>begin
>   Result := False;
>   for n := 0 to Count - 1 do
>     Result := Result or CheckAccount(Items[n]);
>end;
>
>What happens here is that as soon as 1 CheckAccount returns True then it
>stop calling CheckAccount. I solved this with increment a counter for
>each CheckAccount and Result := Counter > 0; But this kind of
>optimization is for me a bug, or is it not ?  I discoverd this in D7,
>dont know about previous D versions, however I'm pretty sure I did
>similar things in other projects.
>
>---
>Rgds, Wilfried
>http://www.mestdagh.biz
>
>__________________________________________________
>Delphi-Talk mailing list -> [email protected]
>http://www.elists.org/mailman/listinfo/delphi-talk

Respectfully,

Ralph D. Wilson II                                 Web 
Site:  <http:thewizardsguild.com>
Systems 
Analyst                                   Email: 
<[EMAIL PROTECTED]>
San Antonio, TX 78259                       Alt Email:   <[EMAIL PROTECTED]>
H: (210) 497-2643
M: (210) 387-7744

"Any sufficiently advanced technology is indistinguishable from 
magic."  A.C.Clark 

__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk

Reply via email to