diff --git a/Core/Array.cpp b/Core/Array.cpp index df4df2a4..7e149bd1 100644 --- a/Core/Array.cpp +++ b/Core/Array.cpp @@ -1,6 +1,4 @@ -//#include - -#include "_Core.h" +#include "_Core.h" #include "Type.h" #include "Buffer.h" diff --git a/Core/Buffer.cpp b/Core/Buffer.cpp index d972339d..50d4e379 100644 --- a/Core/Buffer.cpp +++ b/Core/Buffer.cpp @@ -1,6 +1,4 @@ -//#include - -#include "_Core.h" +#include "_Core.h" #include "Buffer.h" #include "SString.h" @@ -347,7 +345,7 @@ int Buffer::CompareTo(const Buffer& bs) const int Buffer::CompareTo(const void* ptr, int len) const { - if(len < 0) len = 0xFFFF; + if(len < 0) len = _Length; // 同一个指针,长度决定大小 if(_Arr == ptr) return _Length - len; @@ -408,7 +406,7 @@ void memset(byte* ptr, byte item, uint len) // 为了让中间部分凑够4字节对齐 int n = (uint)p & 0x03; - for(int i=0; i0; i++, len--) + while(n-- && len--) *p++ = item; // 中间部分,4字节对齐 @@ -416,9 +414,11 @@ void memset(byte* ptr, byte item, uint len) { int v = (item << 24) | (item << 16) | (item << 8) | item; int* pi = (int*)p; - for(; len>0; len-=4) + n = len >> 2; + while(n--) *pi++ = v; p = (byte*)pi; + len &= 0x03; } // 结尾部分 @@ -436,7 +436,7 @@ void memcpy(byte* dst, const byte* src, uint len) if(nd == ns) { // 为了让中间部分凑够4字节对齐 - for(int i=0; i0; i++, len--) + while(nd-- && len--) *dst++ = *src++; // 中间部分,4字节对齐 @@ -444,10 +444,12 @@ void memcpy(byte* dst, const byte* src, uint len) { int* pd = (int*)dst; int* ps = (int*)src; - for(; len>0; len-=4) + ns = len >> 2; + while(ns--) *pd++ = *ps++; dst = (byte*)pd; src = (byte*)ps; + len &= 0x03; } } diff --git a/Core/String.cpp b/Core/String.cpp index 9ac94438..ba681a27 100644 --- a/Core/String.cpp +++ b/Core/String.cpp @@ -1,6 +1,5 @@ #include #include -//#include #include #include #include diff --git a/Message/BinaryPair.cpp b/Message/BinaryPair.cpp index be2d4cd8..69aa851b 100644 --- a/Message/BinaryPair.cpp +++ b/Message/BinaryPair.cpp @@ -1,7 +1,5 @@ #include "BinaryPair.h" -//#include - // 初始化消息,各字段为0 /*BinaryPair::BinaryPair(Buffer& bs) { diff --git a/Test/BufferTest.cpp b/Test/BufferTest.cpp index 246ce6dd..b39fb174 100644 --- a/Test/BufferTest.cpp +++ b/Test/BufferTest.cpp @@ -1,7 +1,5 @@ #include "Sys.h" -//#include - #if DEBUG static void TestAssign() {