Unified · Split
| @@ -1269,13 +1269,11 @@ namespace GSF.IO · 1268 unmodified lines | ||
| 1269 | 1269 | if ((object)record != null) |
| 1270 | 1270 | { |
| 1271 | 1271 | int lastRecordIndex = (object)m_fileRecords == null ? RecordsOnDisk : RecordsInMemory; |
| 1272 | − if (recordIndex > lastRecordIndex + 1) | |
| 1272 | + | |
| 1273 | + // Write missing intermediate records. | |
| 1274 | + for (int i = lastRecordIndex + 1; i < recordIndex; i++) | |
| 1273 | 1275 | { |
| 1274 | − // Write missing intermediate records. | |
| 1275 | − for (int i = lastRecordIndex + 1; i < recordIndex; i++) | |
| 1276 | − { | |
| 1277 | − Write(i, CreateNewRecord(i)); | |
| 1278 | − } | |
| 1276 | + Write(i, CreateNewRecord(i)); | |
| 1279 | 1277 | } |
| 1280 | 1278 | |
| 1281 | 1279 | if ((object)m_fileRecords == null) |
| @@ -1287,6 +1285,7 @@ namespace GSF.IO · 5 unmodified lines | ||
| 1287 | 1285 | { |
| 1288 | 1286 | // Update in-memory record list. |
| 1289 | 1287 | lastRecordIndex = RecordsInMemory; |
| 1288 | + | |
| 1290 | 1289 | if (recordIndex == lastRecordIndex + 1) |
| 1291 | 1290 | { |
| 1292 | 1291 | // Add new record. |
| @@ -1491,17 +1490,23 @@ namespace GSF.IO · 198 unmodified lines | ||
| 1491 | 1490 | private void WriteToDisk(IEnumerable<T> records) |
| 1492 | 1491 | { |
| 1493 | 1492 | // Write all records to disk. |
| 1494 | − int index = 0; | |
| 1493 | + int count = 0; | |
| 1495 | 1494 | |
| 1496 | − foreach (T item in records) | |
| 1495 | + lock (m_fileData) | |
| 1497 | 1496 | { |
| 1498 | − WriteToDisk(++index, item); | |
| 1497 | + m_fileData.Seek(0L, SeekOrigin.Begin); | |
| 1498 | + | |
| 1499 | + foreach (T item in records) | |
| 1500 | + { | |
| 1501 | + item.CopyBinaryImageToStream(m_fileData); | |
| 1502 | + count++; | |
| 1503 | + } | |
| 1499 | 1504 | } |
| 1500 | 1505 | |
| 1501 | 1506 | // Discard previously existing records that were not written. |
| 1502 | 1507 | lock (m_fileData) |
| 1503 | 1508 | { |
| 1504 | − m_fileData.SetLength(index * m_recordBuffer.Length); | |
| 1509 | + m_fileData.SetLength(count * m_recordBuffer.Length); | |
| 1505 | 1510 | } |
| 1506 | 1511 | } |
| 1507 | 1512 | |