FastSwap
Short summary
Fast element swap operation of two given pointers, optimized for performance.
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| object1 | POINTER TO __XWORD | - | input |
| object2 | POINTER TO __XWORD | - | input |
Code
Declaration
FUNCTION FastSwap
VAR_INPUT
object1 :POINTER TO __XWORD;
object2 :POINTER TO __XWORD;
END_VAR
Implementation
RETURN(object1 = object2);
RETURN(object1 = 0 OR object2 = 0);
object1^ := object2^ XOR object1^;
object2^ := object2^ XOR object1^;
object1^ := object2^ XOR object1^;