Beispiel #1
0
        private void CacheDelta(ObjectToPack srcObj, ObjectToPack resObj)
        {
            if (int.MaxValue < bestDelta.Length())
            {
                return;
            }
            int rawsz = (int)bestDelta.Length();

            if (deltaCache.CanCache(rawsz, srcObj, resObj))
            {
                try
                {
                    byte[] zbuf = new byte[DeflateBound(rawsz)];
                    DeltaWindow.ZipStream zs = new DeltaWindow.ZipStream(Deflater(), zbuf);
                    bestDelta.WriteTo(zs, null);
                    bestDelta = null;
                    int len = zs.Finish();
                    resObj.SetCachedDelta(deltaCache.Cache(zbuf, len, rawsz));
                    resObj.SetCachedSize(rawsz);
                }
                catch (IOException)
                {
                    deltaCache.Credit(rawsz);
                }
                catch (OutOfMemoryException)
                {
                    deltaCache.Credit(rawsz);
                }
            }
        }
Beispiel #2
0
 private void CacheDelta(ObjectToPack srcObj, ObjectToPack resObj)
 {
     if (int.MaxValue < bestDelta.Length())
     {
         return;
     }
     int rawsz = (int)bestDelta.Length();
     if (deltaCache.CanCache(rawsz, srcObj, resObj))
     {
         try
         {
             byte[] zbuf = new byte[DeflateBound(rawsz)];
             DeltaWindow.ZipStream zs = new DeltaWindow.ZipStream(Deflater(), zbuf);
             bestDelta.WriteTo(zs, null);
             bestDelta = null;
             int len = zs.Finish();
             resObj.SetCachedDelta(deltaCache.Cache(zbuf, len, rawsz));
             resObj.SetCachedSize(rawsz);
         }
         catch (IOException)
         {
             deltaCache.Credit(rawsz);
         }
         catch (OutOfMemoryException)
         {
             deltaCache.Credit(rawsz);
         }
     }
 }