優化基於體系結構的實現

我們可以為僅支援未對齊讀/寫的體系結構優化一個簡單的 xor 函式,方法是建立兩個定義函式的檔案,併為它們新增構建約束字首(對於 xor 程式碼的實際示例,這裡的範圍超出範圍,請參閱 crypto/cipher/xor.go in 標準庫):

// +build 386 amd64 s390x

package cipher

func xorBytes(dst, a, b []byte) int { /* This function uses unaligned reads / writes to optimize the operation */ }

以及其他架構:

// +build !386,!amd64,!s390x

package cipher

func xorBytes(dst, a, b []byte) int { /* This version of the function just loops and xors */ }