From 9a5b15dc1eda4f34496bb942d78f0df4e975b469 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 29 Mar 2019 17:57:24 -0700 Subject: [PATCH] [C++11] Replace BEInt.set() with operator= --- src/hb-machinery.hh | 15 +++++++++++---- src/hb-open-type.hh | 8 ++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index 80bbfa645..9bd583a3b 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -682,7 +682,11 @@ template struct BEInt { public: - void set (Type V) { v = V; } + BEInt& operator = (Type V) + { + v = V; + return *this; + } operator Type () const { return v; } private: uint8_t v; }; @@ -690,10 +694,11 @@ template struct BEInt { public: - void set (Type V) + BEInt& operator = (Type V) { v[0] = (V >> 8) & 0xFF; v[1] = (V ) & 0xFF; + return *this; } operator Type () const { @@ -718,11 +723,12 @@ template struct BEInt { public: - void set (Type V) + BEInt& operator = (Type V) { v[0] = (V >> 16) & 0xFF; v[1] = (V >> 8) & 0xFF; v[2] = (V ) & 0xFF; + return *this; } operator Type () const { @@ -737,12 +743,13 @@ struct BEInt { public: typedef Type type; - void set (Type V) + BEInt& operator = (Type V) { v[0] = (V >> 24) & 0xFF; v[1] = (V >> 16) & 0xFF; v[2] = (V >> 8) & 0xFF; v[3] = (V ) & 0xFF; + return *this; } operator Type () const { diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 0cccda7fb..68efd9d19 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -59,8 +59,8 @@ struct IntType typedef Type type; typedef typename hb_signedness_int (hb_is_signed (Type)) wide_type; - IntType& operator = (wide_type i) { v.set (i); return *this; } - void set (wide_type i) { v.set (i); } + IntType& operator = (wide_type i) { v = i; return *this; } + void set (wide_type i) { v = i; } operator wide_type () const { return v; } bool operator == (const IntType &o) const { return (Type) v == (Type) o.v; } bool operator != (const IntType &o) const { return !(*this == o); } @@ -109,7 +109,7 @@ struct F2DOT14 : HBINT16 { // 16384 means 1<<14 float to_float () const { return ((int32_t) v) / 16384.f; } - void set_float (float f) { v.set (round (f * 16384.f)); } + void set_float (float f) { v = round (f * 16384.f); } public: DEFINE_SIZE_STATIC (2); }; @@ -119,7 +119,7 @@ struct Fixed : HBINT32 { // 65536 means 1<<16 float to_float () const { return ((int32_t) v) / 65536.f; } - void set_float (float f) { v.set (round (f * 65536.f)); } + void set_float (float f) { v = round (f * 65536.f); } public: DEFINE_SIZE_STATIC (4); };