<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -51,7 +51,8 @@ Reader::Reader(unsigned int mode)
       m_error(false), 
       m_mode(mode),
       m_linenum(0),
-      m_charnum(0)
+      m_charnum(0),
+      m_currentReadOffset(0)
 {
 }
 
@@ -680,26 +681,35 @@ Reader::readProperty(PropertyInfo&amp; prop)
     //  Cache the offset pointer
     //
 
-    prop.offset = tell();
+    if( m_currentReadOffset == 0 )
+    {
+        // Offset can never be zero here, so it must be
+        // uninitialized.  Set it to the real file position.
+        m_currentReadOffset = tell();
+    }
+
+    prop.offset = m_currentReadOffset;
     bool readok = false;
 
     if (prop.requested)
     {
         if ((buffer = (char*)data(prop, bytes)))
         {
+            // Do we need to be somewhere else?
+            if(m_currentReadOffset != tell())
+            {
+                // If so, move the actual file pointer there.
+                seekForward(m_currentReadOffset - tell());
+            }
             read(buffer, bytes);
             readok = true;
         }
-        else
-        {
-            seekForward(bytes);
-        }
-    }
-    else
-    {
-        seekForward(bytes);
     }
 
+    // Move the 'virtual' file offset forward by  the data
+    // size of this property, whether we read it or not.
+    m_currentReadOffset += bytes; 
+
     if (m_error) return false;
 
     if (readok)
@@ -920,6 +930,11 @@ void Reader::seekTo(size_t bytes)
         gzseek(m_gzfile, bytes, SEEK_SET);
     }
 #endif
+
+    //
+    // Copy the 'real' file pointer to our virtual one.
+    //
+    m_currentReadOffset = tell();
 }
 
 int Reader::tell()</diff>
      <filename>lib/Gto/Reader.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -382,6 +382,7 @@ private:
     int                 m_charnum;
     ByteArray           m_buffer;
     TypeSpec            m_currentType;
+    size_t              m_currentReadOffset;
 };
 
 template &lt;typename T&gt;</diff>
      <filename>lib/Gto/Reader.h</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>435bb9b1be78760b9590b45ad91719e499f5800b</id>
    </parent>
  </parents>
  <author>
    <name>Mike Root</name>
    <email>mike-gto@redpointmaine.com</email>
  </author>
  <url>http://github.com/jimhourihan/gto/commit/b1ba195f3672a26fdb8803c119fb5ab8e5d16744</url>
  <id>b1ba195f3672a26fdb8803c119fb5ab8e5d16744</id>
  <committed-date>2009-05-16T11:32:12-07:00</committed-date>
  <authored-date>2009-05-16T11:32:12-07:00</authored-date>
  <message>Optimize seek patterns in compressed binary gtos</message>
  <tree>cd6271b1e756b4bea1fd225bd8f2ed70fe0389ff</tree>
  <committer>
    <name>Mike Root</name>
    <email>mike-gto@redpointmaine.com</email>
  </committer>
</commit>
