Skip to content

Commit

Permalink
refactor: Optimized project module[047850]
Browse files Browse the repository at this point in the history
  • Loading branch information
Greedysky committed Sep 9, 2021
1 parent 8cc3737 commit 560614c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 34 deletions.
10 changes: 5 additions & 5 deletions TTKThirdParty/zxing/bigint/BigInteger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ BigInteger::BigInteger(unsigned short x) : mag(x) { sign = mag.isZero() ? zero :
// For signed input, determine the desired magnitude and sign separately.

namespace {
template <class X, class UX>
template <typename X, typename UX>
BigInteger::Blk magOf(X x) {
/* UX(...) cast needed to stop short(-2^15), which negates to
* itself, from sign-extending in the conversion to Blk. */
return BigInteger::Blk(x < 0 ? UX(-x) : x);
}
template <class X>
template <typename X>
BigInteger::Sign signOf(X x) {
return (x == 0) ? BigInteger::zero
: (x > 0) ? BigInteger::positive
Expand All @@ -84,12 +84,12 @@ BigInteger::BigInteger(short x) : sign(signOf(x)), mag(magOf<short, unsigned sho
* The friend is a separate function rather than
* BigInteger::convertToUnsignedPrimitive to avoid requiring BigUnsigned to
* declare BigInteger. */
template <class X>
template <typename X>
inline X convertBigUnsignedToPrimitiveAccess(const BigUnsigned &a) {
return a.convertToPrimitive<X>();
}

template <class X>
template <typename X>
X BigInteger::convertToUnsignedPrimitive() const {
if (sign == negative)
throw "BigInteger::to<Primitive>: "
Expand All @@ -100,7 +100,7 @@ X BigInteger::convertToUnsignedPrimitive() const {

/* Similar to BigUnsigned::convertToPrimitive, but split into two cases for
* nonnegative and negative numbers. */
template <class X, class UX>
template <typename X, typename UX>
X BigInteger::convertToSignedPrimitive() const {
if (sign == zero)
return 0;
Expand Down
4 changes: 2 additions & 2 deletions TTKThirdParty/zxing/bigint/BigInteger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public:
short toShort () const;
protected:
// Helper
template <class X> X convertToUnsignedPrimitive() const;
template <class X, class UX> X convertToSignedPrimitive() const;
template <typename X> X convertToUnsignedPrimitive() const;
template <typename X, typename UX> X convertToSignedPrimitive() const;
public:

// ACCESSORS
Expand Down
4 changes: 2 additions & 2 deletions TTKThirdParty/zxing/bigint/BigIntegerUtils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ BigUnsigned stringToBigUnsigned(const std::string &s);
BigInteger stringToBigInteger(const std::string &s);

// Creates a BigInteger from data such as `char's; read below for details.
template <class T>
template <typename T>
BigInteger dataToBigInteger(const T* data, BigInteger::Index length, BigInteger::Sign sign);

// Outputs x to os, obeying the flags `dec', `hex', `bin', and `showbase'.
Expand All @@ -41,7 +41,7 @@ std::ostream &operator <<(std::ostream &os, const BigInteger &x);
* (2) When a value of `T' is casted to a `Blk', the low bytes of
* the result contain the desired binary data.
*/
template <class T>
template <typename T>
BigInteger dataToBigInteger(const T* data, BigInteger::Index length, BigInteger::Sign sign) {
// really ceiling(numBytes / sizeof(BigInteger::Blk))
unsigned int pieceSizeInBits = 8 * sizeof(T);
Expand Down
18 changes: 9 additions & 9 deletions TTKThirdParty/zxing/bigint/BigUnsigned.hh
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public:
BigUnsigned( short x);
protected:
// Helpers
template <class X> void initFromPrimitive (X x);
template <class X> void initFromSignedPrimitive(X x);
template <typename X> void initFromPrimitive (X x);
template <typename X> void initFromSignedPrimitive(X x);
public:

/* Converters to primitive integer types
Expand All @@ -77,8 +77,8 @@ public:
short toShort () const;
protected:
// Helpers
template <class X> X convertToSignedPrimitive() const;
template <class X> X convertToPrimitive () const;
template <typename X> X convertToSignedPrimitive() const;
template <typename X> X convertToPrimitive () const;
public:

// BIT/BLOCK ACCESSORS
Expand Down Expand Up @@ -236,7 +236,7 @@ public:
unsigned int y);

// See BigInteger.cc.
template <class X>
template <typename X>
friend X convertBigUnsignedToPrimitiveAccess(const BigUnsigned &a);
};

Expand Down Expand Up @@ -352,7 +352,7 @@ inline void BigUnsigned::operator >>=(int b) {
* reduce code duplication. (Don't worry: this is protected and we instantiate
* it only with primitive integer types.) Type X could be signed, but x is
* known to be nonnegative. */
template <class X>
template <typename X>
void BigUnsigned::initFromPrimitive(X x) {
if (x == 0)
; // NumberlikeArray already initialized us to zero.
Expand All @@ -369,7 +369,7 @@ void BigUnsigned::initFromPrimitive(X x) {
* initFromPrimitive and let the compiler optimize it out for unsigned-type
* instantiations, but I wanted to avoid the warning stupidly issued by g++ for
* a condition that is constant in *any* instantiation, even if not in all. */
template <class X>
template <typename X>
void BigUnsigned::initFromSignedPrimitive(X x) {
if (x < 0)
throw "BigUnsigned constructor: "
Expand All @@ -383,7 +383,7 @@ void BigUnsigned::initFromSignedPrimitive(X x) {
/* Template with the same idea as initFromPrimitive. This might be slightly
* slower than the previous version with the masks, but it's much shorter and
* clearer, which is the library's stated goal. */
template <class X>
template <typename X>
X BigUnsigned::convertToPrimitive() const {
if (len == 0)
// The number is zero; return zero.
Expand All @@ -405,7 +405,7 @@ X BigUnsigned::convertToPrimitive() const {
* not a negative one that happened to convert back into the correct nonnegative
* one. (E.g., catch incorrect conversion of 2^31 to the long -2^31.) Again,
* separated to avoid a g++ warning. */
template <class X>
template <typename X>
X BigUnsigned::convertToSignedPrimitive() const {
X x = convertToPrimitive<X>();
if (x >= 0)
Expand Down
16 changes: 8 additions & 8 deletions TTKThirdParty/zxing/bigint/NumberlikeArray.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* public:
* NumberlikeArray< the-type-argument >::getLength;
*/
template <class Blk>
template <typename Blk>
class NumberlikeArray {
public:

Expand Down Expand Up @@ -87,10 +87,10 @@ public:
/* BEGIN TEMPLATE DEFINITIONS. They are present here so that source files that
* include this header file can generate the necessary real definitions. */

template <class Blk>
template <typename Blk>
const unsigned int NumberlikeArray<Blk>::N = 8 * sizeof(Blk);

template <class Blk>
template <typename Blk>
void NumberlikeArray<Blk>::allocate(Index c) {
// If the requested capacity is more than the current capacity...
if (c > cap) {
Expand All @@ -102,7 +102,7 @@ void NumberlikeArray<Blk>::allocate(Index c) {
}
}

template <class Blk>
template <typename Blk>
void NumberlikeArray<Blk>::allocateAndCopy(Index c) {
// If the requested capacity is more than the current capacity...
if (c > cap) {
Expand All @@ -119,7 +119,7 @@ void NumberlikeArray<Blk>::allocateAndCopy(Index c) {
}
}

template <class Blk>
template <typename Blk>
NumberlikeArray<Blk>::NumberlikeArray(const NumberlikeArray<Blk> &x)
: len(x.len) {
// Create array
Expand All @@ -131,7 +131,7 @@ NumberlikeArray<Blk>::NumberlikeArray(const NumberlikeArray<Blk> &x)
blk[i] = x.blk[i];
}

template <class Blk>
template <typename Blk>
void NumberlikeArray<Blk>::operator=(const NumberlikeArray<Blk> &x) {
/* Calls like a = a have no effect; catch them before the aliasing
* causes a problem */
Expand All @@ -147,7 +147,7 @@ void NumberlikeArray<Blk>::operator=(const NumberlikeArray<Blk> &x) {
blk[i] = x.blk[i];
}

template <class Blk>
template <typename Blk>
NumberlikeArray<Blk>::NumberlikeArray(const Blk *b, Index blen)
: cap(blen), len(blen) {
// Create array
Expand All @@ -158,7 +158,7 @@ NumberlikeArray<Blk>::NumberlikeArray(const Blk *b, Index blen)
blk[i] = b[i];
}

template <class Blk>
template <typename Blk>
bool NumberlikeArray<Blk>::operator ==(const NumberlikeArray<Blk> &x) const {
if (len != x.len)
// Definitely unequal.
Expand Down
6 changes: 3 additions & 3 deletions TTKThirdParty/zxing/zxing/common/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

namespace zxing {

template<typename T> class Array : public Counted {
template <typename T> class Array : public Counted {
protected:
public:
std::vector<T> values_;
Expand Down Expand Up @@ -83,7 +83,7 @@ template<typename T> class Array : public Counted {
}
};

template<typename T> class ArrayRef : public Counted {
template <typename T> class ArrayRef : public Counted {
private:
public:
Array<T> *array_;
Expand All @@ -107,7 +107,7 @@ template<typename T> class ArrayRef : public Counted {
reset(other.array_);
}

template<class Y>
template <typename Y>
ArrayRef(const ArrayRef<Y> &other) :
array_(0) {
reset(static_cast<const Array<T> *>(other.array_));
Expand Down
10 changes: 5 additions & 5 deletions TTKThirdParty/zxing/zxing/common/Counted.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TTK_MODULE_EXPORT Counted {
};

/* counting reference to reference-counted objects */
template<typename T> class TTK_MODULE_EXPORT Ref {
template <typename T> class TTK_MODULE_EXPORT Ref {
private:
public:
T *object_;
Expand All @@ -66,7 +66,7 @@ template<typename T> class TTK_MODULE_EXPORT Ref {
reset(other.object_);
}

template<class Y>
template <typename Y>
Ref(const Ref<Y> &other) :
object_(0) {
reset(other.object_);
Expand All @@ -91,7 +91,7 @@ template<typename T> class TTK_MODULE_EXPORT Ref {
reset(other.object_);
return *this;
}
template<class Y>
template <typename Y>
Ref& operator=(const Ref<Y> &other) {
reset(other.object_);
return *this;
Expand All @@ -100,7 +100,7 @@ template<typename T> class TTK_MODULE_EXPORT Ref {
reset(o);
return *this;
}
template<class Y>
template <typename Y>
Ref& operator=(Y* o) {
reset(o);
return *this;
Expand All @@ -122,7 +122,7 @@ template<typename T> class TTK_MODULE_EXPORT Ref {
bool operator==(const Ref &other) const {
return object_ == other.object_ || *object_ == *(other.object_);
}
template<class Y>
template <typename Y>
bool operator==(const Ref<Y> &other) const {
return object_ == other.object_ || *object_ == *(other.object_);
}
Expand Down

0 comments on commit 560614c

Please sign in to comment.