"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "include/rapidjson/internal/biginteger.h" between
rapidjson-1.0.2.tar.gz and rapidjson-1.1.0.tar.gz

About: RapidJSON is a fast JSON parser/generator for C++ with both SAX/DOM style API.

biginteger.h  (rapidjson-1.0.2):biginteger.h  (rapidjson-1.1.0)
skipping to change at line 22 skipping to change at line 22
// CONDITIONS OF ANY KIND, either express or implied. See the License for the // CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License. // specific language governing permissions and limitations under the License.
#ifndef RAPIDJSON_BIGINTEGER_H_ #ifndef RAPIDJSON_BIGINTEGER_H_
#define RAPIDJSON_BIGINTEGER_H_ #define RAPIDJSON_BIGINTEGER_H_
#include "../rapidjson.h" #include "../rapidjson.h"
#if defined(_MSC_VER) && defined(_M_AMD64) #if defined(_MSC_VER) && defined(_M_AMD64)
#include <intrin.h> // for _umul128 #include <intrin.h> // for _umul128
#pragma intrinsic(_umul128)
#endif #endif
RAPIDJSON_NAMESPACE_BEGIN RAPIDJSON_NAMESPACE_BEGIN
namespace internal { namespace internal {
class BigInteger { class BigInteger {
public: public:
typedef uint64_t Type; typedef uint64_t Type;
BigInteger(const BigInteger& rhs) : count_(rhs.count_) { BigInteger(const BigInteger& rhs) : count_(rhs.count_) {
skipping to change at line 54 skipping to change at line 55
while (length >= kMaxDigitPerIteration) { while (length >= kMaxDigitPerIteration) {
AppendDecimal64(decimals + i, decimals + i + kMaxDigitPerIteration); AppendDecimal64(decimals + i, decimals + i + kMaxDigitPerIteration);
length -= kMaxDigitPerIteration; length -= kMaxDigitPerIteration;
i += kMaxDigitPerIteration; i += kMaxDigitPerIteration;
} }
if (length > 0) if (length > 0)
AppendDecimal64(decimals + i, decimals + i + length); AppendDecimal64(decimals + i, decimals + i + length);
} }
BigInteger& operator=(const BigInteger &rhs)
{
if (this != &rhs) {
count_ = rhs.count_;
std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type));
}
return *this;
}
BigInteger& operator=(uint64_t u) { BigInteger& operator=(uint64_t u) {
digits_[0] = u; digits_[0] = u;
count_ = 1; count_ = 1;
return *this; return *this;
} }
BigInteger& operator+=(uint64_t u) { BigInteger& operator+=(uint64_t u) {
Type backup = digits_[0]; Type backup = digits_[0];
digits_[0] += u; digits_[0] += u;
for (size_t i = 0; i < count_ - 1; i++) { for (size_t i = 0; i < count_ - 1; i++) {
skipping to change at line 233 skipping to change at line 243
void PushBack(Type digit) { void PushBack(Type digit) {
RAPIDJSON_ASSERT(count_ < kCapacity); RAPIDJSON_ASSERT(count_ < kCapacity);
digits_[count_++] = digit; digits_[count_++] = digit;
} }
static uint64_t ParseUint64(const char* begin, const char* end) { static uint64_t ParseUint64(const char* begin, const char* end) {
uint64_t r = 0; uint64_t r = 0;
for (const char* p = begin; p != end; ++p) { for (const char* p = begin; p != end; ++p) {
RAPIDJSON_ASSERT(*p >= '0' && *p <= '9'); RAPIDJSON_ASSERT(*p >= '0' && *p <= '9');
r = r * 10 + (*p - '0'); r = r * 10u + static_cast<unsigned>(*p - '0');
} }
return r; return r;
} }
// Assume a * b + k < 2^128 // Assume a * b + k < 2^128
static uint64_t MulAdd64(uint64_t a, uint64_t b, uint64_t k, uint64_t* outHi gh) { static uint64_t MulAdd64(uint64_t a, uint64_t b, uint64_t k, uint64_t* outHi gh) {
#if defined(_MSC_VER) && defined(_M_AMD64) #if defined(_MSC_VER) && defined(_M_AMD64)
uint64_t low = _umul128(a, b, outHigh) + k; uint64_t low = _umul128(a, b, outHigh) + k;
if (low < k) if (low < k)
(*outHigh)++; (*outHigh)++;
 End of changes. 3 change blocks. 
1 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)