From 0150b2d6632c3f7f779e1f5b37d4242ce4f9c311 Mon Sep 17 00:00:00 2001 From: weidai Date: Fri, 4 May 2007 15:33:17 +0000 Subject: [PATCH] speed up xorbuf --- misc.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/misc.cpp b/misc.cpp index d02c5202..305edfdf 100644 --- a/misc.cpp +++ b/misc.cpp @@ -12,24 +12,68 @@ NAMESPACE_BEGIN(CryptoPP) void xorbuf(byte *buf, const byte *mask, size_t count) { - if (((size_t)buf | (size_t)mask | count) % WORD_SIZE == 0) - XorWords((word *)buf, (const word *)mask, count/WORD_SIZE); - else + size_t i; + + if (IsAligned(buf) && IsAligned(mask)) { - for (unsigned int i=0; i(buf) && IsAligned(mask)) + { + for (i=0; i(output) && IsAligned(input) && IsAligned(mask)) { - for (unsigned int i=0; i(output) && IsAligned(input) && IsAligned(mask)) + { + for (i=0; i