Bug 1461556 - Give uint8_clamped a defaulted (and also trivial) default constructor, copy constructor, and copy-assignment operator. (This also allows uint8_clamped to be permissibly memmove'd and memcpy'd.) r=jandem
authorJeff Walden <jwalden@mit.edu>
Wed, 16 May 2018 19:00:04 -0700
changeset 418912 7a053ded7f8039fa6274dbb7b41db2b6b5d751da
parent 418911 353d2ee295913b9d6660f0b8da2102a54c8133bf
child 418913 04a9320069d7e233b88586151bdceb9c353064b4
push id103419
push userjwalden@mit.edu
push dateFri, 18 May 2018 19:33:51 +0000
treeherdermozilla-inbound@7658d2d1e0d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1461556
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1461556 - Give uint8_clamped a defaulted (and also trivial) default constructor, copy constructor, and copy-assignment operator. (This also allows uint8_clamped to be permissibly memmove'd and memcpy'd.) r=jandem
js/src/vm/ArrayBufferObject.h
--- a/js/src/vm/ArrayBufferObject.h
+++ b/js/src/vm/ArrayBufferObject.h
@@ -502,32 +502,29 @@ ArrayBufferObjectMaybeShared& AsArrayBuf
 ArrayBufferObjectMaybeShared& AsArrayBufferMaybeShared(JSObject* obj);
 
 extern uint32_t JS_FASTCALL
 ClampDoubleToUint8(const double x);
 
 struct uint8_clamped {
     uint8_t val;
 
-    uint8_clamped() { }
-    uint8_clamped(const uint8_clamped& other) : val(other.val) { }
+    uint8_clamped() = default;
+    uint8_clamped(const uint8_clamped& other) = default;
 
     // invoke our assignment helpers for constructor conversion
     explicit uint8_clamped(uint8_t x)    { *this = x; }
     explicit uint8_clamped(uint16_t x)   { *this = x; }
     explicit uint8_clamped(uint32_t x)   { *this = x; }
     explicit uint8_clamped(int8_t x)     { *this = x; }
     explicit uint8_clamped(int16_t x)    { *this = x; }
     explicit uint8_clamped(int32_t x)    { *this = x; }
     explicit uint8_clamped(double x)     { *this = x; }
 
-    uint8_clamped& operator=(const uint8_clamped& x) {
-        val = x.val;
-        return *this;
-    }
+    uint8_clamped& operator=(const uint8_clamped& x) = default;
 
     uint8_clamped& operator=(uint8_t x) {
         val = x;
         return *this;
     }
 
     uint8_clamped& operator=(uint16_t x) {
         val = (x > 255) ? 255 : uint8_t(x);