Small fix for index loading
authornvalimak <nvalimak@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Thu, 6 Aug 2009 10:49:10 +0000 (10:49 +0000)
committernvalimak <nvalimak@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Thu, 6 Aug 2009 10:49:10 +0000 (10:49 +0000)
git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/TextCollection@550 3cdefd35-fc62-479d-8e8d-bae585ffb9ca

BlockArray.h

index 3671d08..1ee30c1 100644 (file)
@@ -60,11 +60,8 @@ public:
         if (std::fwrite(&(this->blockLength), sizeof(ulong), 1, file) != 1)
             throw std::runtime_error("BlockArray::Save(): file write error (blockLength).");
     
-        for (ulong offset = 0; offset < n*blockLength/W+1; offset ++)
-        {
-            if (std::fwrite(this->data + offset, sizeof(ulong), 1, file) != 1)
-                throw std::runtime_error("BlockArray::Save(): file write error (data).");
-        }
+        if (std::fwrite(this->data, sizeof(ulong), n*blockLength/W+1, file) != n*blockLength/W+1)
+            throw std::runtime_error("BlockArray::Save(): file write error (data).");
     }
 
     /**
@@ -78,11 +75,8 @@ public:
             throw std::runtime_error("BlockArray::Load(): file read error (blockLength).");
 
         data = new ulong[n*blockLength/W+1];
-        for (ulong offset = 0; offset < n*blockLength/W+1; offset ++)
-        {
-            if (std::fread(this->data + offset, sizeof(ulong), 1, file) != 1)
-                throw std::runtime_error("BlockArray::Load(): file read error (data).");
-        }
+        if (std::fread(this->data, sizeof(ulong), n*blockLength/W+1, file) != n*blockLength/W+1)
+            throw std::runtime_error("BlockArray::Load(): file read error (data).");
     }
 };