[tor-commits] [tor-browser] 06/37: Bug 1754752 - Use initializer lists in some swgl constructors. r=lsalzman, a=RyanVM

gitolite role git at cupani.torproject.org
Wed Jun 22 18:27:15 UTC 2022


This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch tor-browser-91.11.0esr-11.5-1
in repository tor-browser.

commit a2a894e75f7b9f6a89204dfbc76bbfb9cb6b353c
Author: Emilio Cobos Álvarez <emilio at crisal.io>
AuthorDate: Fri Feb 18 09:37:55 2022 +0000

    Bug 1754752 - Use initializer lists in some swgl constructors. r=lsalzman, a=RyanVM
    
    We call it from another constexpr function. Clang seems to not be so
    strict about this.
    
    Differential Revision: https://phabricator.services.mozilla.com/D139078
---
 gfx/wr/swgl/src/glsl.h | 63 +++++++++++++++-----------------------------------
 1 file changed, 18 insertions(+), 45 deletions(-)

diff --git a/gfx/wr/swgl/src/glsl.h b/gfx/wr/swgl/src/glsl.h
index 76437a84eecea..3be1e49d1b2a1 100644
--- a/gfx/wr/swgl/src/glsl.h
+++ b/gfx/wr/swgl/src/glsl.h
@@ -2301,20 +2301,12 @@ struct mat2 {
   const vec2& operator[](int index) const { return data[index]; }
   mat2() = default;
 
-  IMPLICIT mat2(Float a) {
-    data[0] = vec2(a);
-    data[1] = vec2(a);
-  }
+  IMPLICIT constexpr mat2(Float a) : data{vec2(a), vec2(a)} {}
 
-  mat2(vec2 a, vec2 b) {
-    data[0] = a;
-    data[1] = b;
-  }
+  constexpr mat2(vec2 a, vec2 b) : data{a, b} {}
   IMPLICIT mat2(const mat4& mat);
-  IMPLICIT constexpr mat2(mat2_scalar s) {
-    data[0] = vec2(s.data[0]);
-    data[1] = vec2(s.data[1]);
-  }
+  IMPLICIT constexpr mat2(mat2_scalar s)
+      : data{vec2(s.data[0]), vec2(s.data[1])} {}
 
   friend vec2 operator*(mat2 m, vec2 v) {
     vec2 u;
@@ -2404,30 +2396,19 @@ struct mat3 {
   vec3& operator[](int index) { return data[index]; }
   const vec3& operator[](int index) const { return data[index]; }
   mat3() = default;
-  mat3(vec3 a, vec3 b, vec3 c) {
-    data[0] = a;
-    data[1] = b;
-    data[2] = c;
-  }
+  constexpr mat3(vec3 a, vec3 b, vec3 c) : data{a, b, c} {}
 
-  IMPLICIT constexpr mat3(mat3_scalar s) {
-    data[0] = vec3(s.data[0]);
-    data[1] = vec3(s.data[1]);
-    data[2] = vec3(s.data[2]);
-  }
-  constexpr mat3(mat3_scalar s0, mat3_scalar s1, mat3_scalar s2,
-                 mat3_scalar s3) {
-    data[0] = vec3(s0.data[0], s1.data[0], s2.data[0], s3.data[0]);
-    data[1] = vec3(s0.data[1], s1.data[1], s2.data[1], s3.data[1]);
-    data[2] = vec3(s0.data[2], s1.data[2], s2.data[2], s3.data[2]);
-  }
+  IMPLICIT constexpr mat3(mat3_scalar s)
+      : data{vec3(s.data[0]), vec3(s.data[1]), vec3(s.data[2])} {}
+
+  constexpr mat3(mat3_scalar s0, mat3_scalar s1, mat3_scalar s2, mat3_scalar s3)
+      : data{vec3(s0.data[0], s1.data[0], s2.data[0], s3.data[0]),
+             vec3(s0.data[1], s1.data[1], s2.data[1], s3.data[1]),
+             vec3(s0.data[2], s1.data[2], s2.data[2], s3.data[2])} {}
 
   constexpr mat3(Float d1, Float d2, Float d3, Float d4, Float d5, Float d6,
-                 Float d7, Float d8, Float d9) {
-    data[0] = vec3(d1, d2, d3);
-    data[1] = vec3(d4, d5, d6);
-    data[2] = vec3(d7, d8, d9);
-  }
+                 Float d7, Float d8, Float d9)
+      : data{vec3(d1, d2, d3), vec3(d4, d5, d6), vec3(d7, d8, d9)} {}
 
   IMPLICIT mat3(const mat4& mat);
 
@@ -2597,19 +2578,11 @@ struct mat4 {
   vec4 data[4];
 
   mat4() = default;
-  IMPLICIT constexpr mat4(mat4_scalar s) {
-    data[0] = vec4(s.data[0]);
-    data[1] = vec4(s.data[1]);
-    data[2] = vec4(s.data[2]);
-    data[3] = vec4(s.data[3]);
-  }
+  IMPLICIT constexpr mat4(mat4_scalar s)
+      : data{vec4(s.data[0]), vec4(s.data[1]), vec4(s.data[2]),
+             vec4(s.data[3])} {}
 
-  mat4(vec4 a, vec4 b, vec4 c, vec4 d) {
-    data[0] = a;
-    data[1] = b;
-    data[2] = c;
-    data[3] = d;
-  }
+  constexpr mat4(vec4 a, vec4 b, vec4 c, vec4 d) : data{a, b, c, d} {}
 
   vec4& operator[](int index) { return data[index]; }
   const vec4& operator[](int index) const { return data[index]; }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list