Vote UpVote

XOR swap/exchange: nowadays an almost extinct means to exchange two distinct variables of the same size

The Wiert Corner – Almost a year ago, a thread on “premature Delphi optimization” came by on G+ about this code: procedure ExchangeInteger(var AValue1, AValue2: Integer); begin AValue1 := AValue1 xor AValue2; AValue2 := AValue1 xor AValue2; AValue1 := AValue1 xor AValue2; end; I don’t think that was premature optimization, just some code from an old fart that had already been programming in the era where processors had reasons to use it: limited instruction set few registers limited amount of RAM. Back then, the only efficient way to exchange two variables of the same data type was ...
Favorite? Off-Topic? Jeroen Pluimers @ 2013-12-19 06:00


Visits: 509
Votes: 3
Favorites: 0
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News


Please login or register to use this functionality.
(click on this box to dismiss)