[poppler] poppler/Function.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jan 18 18:14:32 UTC 2019


 poppler/Function.cc |   27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

New commits:
commit 98f7cf7cf126a1d28797b4ce9095aefe9656e954
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri Jan 18 17:18:39 2019 +0100

    Fix e[0] gcc warning

diff --git a/poppler/Function.cc b/poppler/Function.cc
index 2f53a75d..b8e8e077 100644
--- a/poppler/Function.cc
+++ b/poppler/Function.cc
@@ -441,23 +441,24 @@ void SampledFunction::transform(const double *in, double *out) const {
   int e[funcMaxInputs];
   double efrac0[funcMaxInputs];
   double efrac1[funcMaxInputs];
-  int i, j, k, idx0, t;
 
   // check the cache
-  for (i = 0; i < m; ++i) {
+  bool inCache = true;
+  for (int i = 0; i < m; ++i) {
     if (in[i] != cacheIn[i]) {
+      inCache = false;
       break;
     }
   }
-  if (i == m) {
-    for (i = 0; i < n; ++i) {
+  if (inCache) {
+    for (int i = 0; i < n; ++i) {
       out[i] = cacheOut[i];
     }
     return;
   }
 
   // map input values into sample array
-  for (i = 0; i < m; ++i) {
+  for (int i = 0; i < m; ++i) {
     x = (in[i] - domain[i][0]) * inputMul[i] + encode[i][0];
     if (x < 0 || x != x) {  // x!=x is a more portable version of isnan(x)
       x = 0;
@@ -474,17 +475,17 @@ void SampledFunction::transform(const double *in, double *out) const {
   }
 
   // compute index for the first sample to be used
-  idx0 = 0;
-  for (k = m - 1; k >= 1; --k) {
+  int idx0 = 0;
+  for (int k = m - 1; k >= 1; --k) {
     idx0 = (idx0 + e[k]) * sampleSize[k-1];
   }
   idx0 = (idx0 + e[0]) * n;
 
   // for each output, do m-linear interpolation
-  for (i = 0; i < n; ++i) {
+  for (int i = 0; i < n; ++i) {
 
     // pull 2^m values out of the sample array
-    for (j = 0; j < (1<<m); ++j) {
+    for (int j = 0; j < (1<<m); ++j) {
       int idx = idx0 + idxOffset[j] + i;
       if (likely(idx >= 0 && idx < nSamples)) {
         sBuf[j] = samples[idx];
@@ -494,8 +495,8 @@ void SampledFunction::transform(const double *in, double *out) const {
     }
 
     // do m sets of interpolations
-    for (j = 0, t = (1<<m); j < m; ++j, t >>= 1) {
-      for (k = 0; k < t; k += 2) {
+    for (int j = 0, t = (1<<m); j < m; ++j, t >>= 1) {
+      for (int k = 0; k < t; k += 2) {
 	sBuf[k >> 1] = efrac0[j] * sBuf[k] + efrac1[j] * sBuf[k+1];
       }
     }
@@ -510,10 +511,10 @@ void SampledFunction::transform(const double *in, double *out) const {
   }
 
   // save current result in the cache
-  for (i = 0; i < m; ++i) {
+  for (int i = 0; i < m; ++i) {
     cacheIn[i] = in[i];
   }
-  for (i = 0; i < n; ++i) {
+  for (int i = 0; i < n; ++i) {
     cacheOut[i] = out[i];
   }
 }


More information about the poppler mailing list