Skip to main content

FastSwap

Short summary

Fast element swap operation of two given pointers, optimized for performance.

Parameters

NameTypeCommentKind
object1POINTER TO __XWORD-input
object2POINTER 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^;