From f54da94d03bd3175c2e78194fa3a61f3d9dc865f Mon Sep 17 00:00:00 2001 From: v2ray Date: Sat, 18 Jun 2016 02:19:18 +0200 Subject: [PATCH] update asm code --- transport/internet/kcp/xor.go | 12 ++++++++++-- .../internet/kcp/{xor.amd64.s => xor_amd64.s} | 0 transport/internet/kcp/xor_other.go | 15 --------------- 3 files changed, 10 insertions(+), 17 deletions(-) rename transport/internet/kcp/{xor.amd64.s => xor_amd64.s} (100%) delete mode 100644 transport/internet/kcp/xor_other.go diff --git a/transport/internet/kcp/xor.go b/transport/internet/kcp/xor.go index f28659044..b9f39f2bf 100644 --- a/transport/internet/kcp/xor.go +++ b/transport/internet/kcp/xor.go @@ -1,7 +1,15 @@ package kcp // xorfwd performs XOR forwards in words, x[i] ^= x[i-4], i from 0 to len -func xorfwd(x []byte) +func xorfwd(x []byte) { + for i := 4; i < len(x); i++ { + x[i] ^= x[i-4] + } +} // xorbkd performs XOR backwords in words, x[i] ^= x[i-4], i from len to 0 -func xorbkd(x []byte) +func xorbkd(x []byte) { + for i := len(x) - 1; i >= 4; i-- { + x[i] ^= x[i-4] + } +} diff --git a/transport/internet/kcp/xor.amd64.s b/transport/internet/kcp/xor_amd64.s similarity index 100% rename from transport/internet/kcp/xor.amd64.s rename to transport/internet/kcp/xor_amd64.s diff --git a/transport/internet/kcp/xor_other.go b/transport/internet/kcp/xor_other.go deleted file mode 100644 index 515d0cbd8..000000000 --- a/transport/internet/kcp/xor_other.go +++ /dev/null @@ -1,15 +0,0 @@ -// +build !amd64 - -package kcp - -func xorfwd(x []byte) { - for i := 4; i < len(x); i++ { - x[i] ^= x[i-4] - } -} - -func xorbkd(x []byte) { - for i := len(x) - 1; i >= 0; i-- { - x[i] ^= x[i-4] - } -}