[Bf-blender-cvs] [418fdee5dc9] master: Cleanup: Mark large arrays of of constant data as const.

Lazydodo noreply at git.blender.org
Sun Aug 4 22:24:39 CEST 2019


Commit: 418fdee5dc9950fef17c1d2fc9f6137af5a42ac9
Author: Lazydodo
Date:   Sun Aug 4 14:24:29 2019 -0600
Branches: master
https://developer.blender.org/rB418fdee5dc9950fef17c1d2fc9f6137af5a42ac9

Cleanup: Mark large arrays of of constant data as const.

For background information see D5345

Reviewers: brecht, sergey

Differential Revision: https://developer.blender.org/D5345

===================================================================

M	intern/cycles/render/sobol.cpp
M	source/blender/datatoc/datatoc.c

===================================================================

diff --git a/intern/cycles/render/sobol.cpp b/intern/cycles/render/sobol.cpp
index 5fb3531b03b..c821249b239 100644
--- a/intern/cycles/render/sobol.cpp
+++ b/intern/cycles/render/sobol.cpp
@@ -62,7 +62,7 @@ typedef struct SobolDirectionNumbers {
 
 /* Keep simple alignment. */
 /* clang-format off */
-static SobolDirectionNumbers SOBOL_NUMBERS[SOBOL_MAX_DIMENSIONS - 1] = {
+static const SobolDirectionNumbers SOBOL_NUMBERS[SOBOL_MAX_DIMENSIONS - 1] = {
 {2, 1, 0, {1}},
 {3, 2, 1, {1, 3}},
 {4, 3, 1, {1, 3, 1}},
@@ -21279,10 +21279,10 @@ void sobol_generate_direction_vectors(uint vectors[][SOBOL_BITS], int dimensions
     v[i] = 1 << (31 - i);  // all m's = 1
 
   for (int dim = 1; dim < dimensions; dim++) {
-    SobolDirectionNumbers *numbers = &SOBOL_NUMBERS[dim - 1];
-    uint s = numbers->s;
-    uint a = numbers->a;
-    uint *m = numbers->m;
+    const SobolDirectionNumbers *numbers = &SOBOL_NUMBERS[dim - 1];
+    const uint s = numbers->s;
+    const uint a = numbers->a;
+    const uint *m = numbers->m;
 
     v = vectors[dim];
 
diff --git a/source/blender/datatoc/datatoc.c b/source/blender/datatoc/datatoc.c
index 6fe2650d66c..cf8d17e5e7e 100644
--- a/source/blender/datatoc/datatoc.c
+++ b/source/blender/datatoc/datatoc.c
@@ -94,11 +94,11 @@ int main(int argc, char **argv)
   fprintf(fpout, "/* DataToC output of file <%s> */\n\n", argv[1]);
 
   /* Quiet 'missing-variable-declarations' warning. */
-  fprintf(fpout, "extern int datatoc_%s_size;\n", argv[1]);
-  fprintf(fpout, "extern char datatoc_%s[];\n\n", argv[1]);
+  fprintf(fpout, "extern const int datatoc_%s_size;\n", argv[1]);
+  fprintf(fpout, "extern const char datatoc_%s[];\n\n", argv[1]);
 
-  fprintf(fpout, "int datatoc_%s_size = %d;\n", argv[1], (int)size);
-  fprintf(fpout, "char datatoc_%s[] = {\n", argv[1]);
+  fprintf(fpout, "const int datatoc_%s_size = %d;\n", argv[1], (int)size);
+  fprintf(fpout, "const char datatoc_%s[] = {\n", argv[1]);
   while (size--) {
     /* if we want to open in an editor
      * this is nicer to avoid very long lines */



More information about the Bf-blender-cvs mailing list