sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1487429 - /sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
Date Wed, 29 May 2013 10:11:13 GMT
Author: desruisseaux
Date: Wed May 29 10:11:12 2013
New Revision: 1487429

URL: http://svn.apache.org/r1487429
Log:
Discard obolete marks.

Modified:
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java?rev=1487429&r1=1487428&r2=1487429&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
[UTF-8] Wed May 29 10:11:12 2013
@@ -88,10 +88,10 @@ public class ChannelImageInputStream ext
      */
     private static final class Mark {
         final long position;
-        final int  bitOffset;
-        final Mark next;
+        final byte bitOffset;
+        Mark next;
 
-        Mark(long position, int bitOffset, Mark next) {
+        Mark(long position, byte bitOffset, Mark next) {
             this.position  = position;
             this.bitOffset = bitOffset;
             this.next      = next;
@@ -418,7 +418,7 @@ loop:   while ((c = read()) >= 0) {
      */
     @Override
     public final void mark() {
-        mark = new Mark(getStreamPosition(), getBitOffset(), mark);
+        mark = new Mark(getStreamPosition(), (byte) getBitOffset(), mark);
     }
 
     /**
@@ -478,6 +478,20 @@ loop:   while ((c = read()) >= 0) {
         buffer.position(n); // Number of bytes to forget.
         buffer.compact().position(p).limit(r);
         setStreamPosition(currentPosition);
+
+        // Discard obolete marks.
+        Mark parent = null;
+        for (Mark m = mark; m != null; m = m.next) {
+            if (m.position < position) {
+                if (parent != null) {
+                    parent.next = null;
+                } else {
+                    mark = null;
+                }
+                break;
+            }
+            parent = m;
+        }
     }
 
     /**



Mime
View raw message