From: Derek <derekwbarnett@gmail.com>
Date: Thu, 21 Oct 2010 19:00:03 +0000 (-0400)
Subject: Fixed NoIndexCaching behavior
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=404ea83ee6e81411bea0ea39f852bb7e68767a8e;p=bamtools.git

Fixed NoIndexCaching behavior

 * Previous commit lacked the post-jump dump of index data when this
mode is selected.
---

diff --git a/src/api/BamIndex.cpp b/src/api/BamIndex.cpp
index 222d96d..e47fd28 100644
--- a/src/api/BamIndex.cpp
+++ b/src/api/BamIndex.cpp
@@ -635,6 +635,12 @@ bool BamStandardIndex::BamStandardIndexPrivate::GetOffsets(const BamRegion& regi
     
     // set flag & return success
     *hasAlignmentsInRegion = (offsets.size() != 0 );
+
+    // if cache mode set to none, dump the data we just loaded
+    if (m_parent->m_cacheMode == BamIndex::NoIndexCaching )
+        ClearReferenceOffsets(region.LeftRefID);
+
+    // return succes
     return true;
 }
 
@@ -1634,6 +1640,12 @@ bool BamToolsIndex::BamToolsIndexPrivate::GetOffset(const BamRegion& region, int
   
     // set flag based on whether an index entry was found for this region
     *hasAlignmentsInRegion = ( indexIter != indexEnd );
+
+    // if cache mode set to none, dump the data we just loaded
+    if (m_parent->m_cacheMode == BamIndex::NoIndexCaching )
+        ClearReferenceOffsets(region.LeftRefID);
+
+    // return success
     return true; 
 }