Autor Beitrag
StrikeLucky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Mo 21.12.09 12:01 
Hallo,

ich würde gerne wissen wo der Unterschied zwischen

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
  Inc(i);

  //und

  i := i + 1;

liegt bzw. welche Variante Vorteile und Nachteile hat.

Danke
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 21.12.09 12:08 
Moin und :welcome: im Forum!

AFAIK gibt´s da keinen Unterschied, Inc() dürfte leicht schneller sein. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
JoelH
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 806
Erhaltene Danke: 17

Win10
Delphi Alexandria 11.2 Patch 1
BeitragVerfasst: Mo 21.12.09 12:11 

_________________
mfg. Joel
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 21.12.09 12:49 
@Narses: Doch, es gibt einen:

Inc(Ptr); inkrementiert nicht um eines, sondern basierend auf dem C-Verhalten (Also Länge des referenzierten Datentyps). Ptr := Ptr+1; ist unter Delphi dagegen nicht erlaubt (bzw. dürfte recht bizarres Verhalten zeigen).

Für Ordinaltypen ist das Verhalten identisch und erzeugt AFAIR sogar den gleichen ASM-Source.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 21.12.09 12:59 
Moin!

user profile iconBenBE hat folgendes geschrieben Zum zitierten Posting springen:
@Narses: Doch, es gibt einen:

Inc(Ptr); inkrementiert nicht um eines
Ist schon klar, da er aber mit "i" wohl einen Integer meint, habe ich das mal wegoptimiert. ;) Wenn man Inc() auf Pointer anwendet, fragt man nicht mehr nach dem Unterschied, dann weiß man das... :zwinker:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 21.12.09 13:04 
Nagut ... dann erwähn ich halt mal noch, dass Inc auch einen zweiten Parameter hat ... :mrgreen:

Wofür der ist, dürfte man sich ja vorstellen können ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 21.12.09 13:08 
OK, du hast gewonnen und ich das letzte Wort. :mrgreen: Deal? :beer: (rhetorische Frage)

_________________
There are 10 types of people - those who understand binary and those who don´t.