[poppler] poppler/GfxState.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Tue Feb 3 12:36:06 PST 2009


 poppler/GfxState.cc |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 3a21dafa46d42d86daec440a85b9d63b292a3c88
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Feb 3 21:33:00 2009 +0100

    Fix cache shifting
    
    If we do
      for (i = 0;i < GFX_ICCBASED_CACHE_SIZE-1 && cache[i].num > 0;i++) {
        cache[i+1] = cache[i];
    what we do at the end is copy position 0 to all others so
    we need to do it in the reverse order

diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 0de4840..646f056 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -16,7 +16,7 @@
 // Copyright (C) 2005 Kristian Høgsberg <krh at redhat.com>
 // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff at infidigm.net>
 // Copyright (C) 2006 Carlos Garcia Campos <carlosgc at gnome.org>
-// Copyright (C) 2006-2008 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006-2009 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2009 Koji Otani <sho at bbr.jp>
 //
 // To see a description of the changes please see the Changelog file that
@@ -1687,8 +1687,8 @@ GfxICCBasedColorSpace *GfxICCBasedCache::lookup(int numA, int genA)
       int j;
       GfxICCBasedCache hit = cache[i];
 
-      for (j = 0;j < i;j++) {
-	cache[j+1] = cache[j];
+      for (j = i;j > 0;j--) {
+	if (cache[j - 1].num > 0) cache[j] = cache[j-1];
       }
       cache[0] = hit;
       return (GfxICCBasedColorSpace *)hit.colorSpace->copy();
@@ -1705,8 +1705,8 @@ void GfxICCBasedCache::put(int numA, int genA,
   if (cache[GFX_ICCBASED_CACHE_SIZE-1].num > 0) {
     delete cache[GFX_ICCBASED_CACHE_SIZE-1].colorSpace;
   }
-  for (i = 0;i < GFX_ICCBASED_CACHE_SIZE-1 && cache[i].num > 0;i++) {
-    cache[i+1] = cache[i];
+  for (i = GFX_ICCBASED_CACHE_SIZE; i > 0; i--) {
+    if (cache[i - 1].num > 0) cache[i] = cache[i - 1];
   }
   cache[0].num = numA;
   cache[0].gen = genA;


More information about the poppler mailing list