From 6450a89067119296800fc1148bb8a88d26857b6e Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Thu, 10 Jul 2008 11:05:19 -0700 Subject: [PATCH] Make use of size assertions in references where possible. When writing out a reference to what is known to be a complete object, use the size-assertion form of a reference. --- localdb.cc | 2 +- ref.cc | 2 +- subfile.cc | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/localdb.cc b/localdb.cc index cc8a83c..7d93bb1 100644 --- a/localdb.cc +++ b/localdb.cc @@ -295,7 +295,7 @@ ObjectReference LocalDb::FindObject(const string &checksum, int64_t size) } else if (rc == SQLITE_ROW) { ref = ObjectReference(IdToSegment(sqlite3_column_int64(stmt, 0)), (const char *)sqlite3_column_text(stmt, 1)); - ref.set_range(0, size); + ref.set_range(0, size, true); } else { fprintf(stderr, "Could not execute SELECT statement!\n"); ReportError(rc); diff --git a/ref.cc b/ref.cc index 7e92b7a..4020c01 100644 --- a/ref.cc +++ b/ref.cc @@ -99,7 +99,7 @@ string ObjectReference::to_string() const char buf[64]; if (range_exact) { sprintf(buf, "[=%zu]", range_length); - } else if (range_start == 0) { + } else if (type == REF_ZERO) { sprintf(buf, "[%zu]", range_length); } else { sprintf(buf, "[%zu+%zu]", range_start, range_length); diff --git a/subfile.cc b/subfile.cc index dac7eda..df6d3b2 100644 --- a/subfile.cc +++ b/subfile.cc @@ -267,6 +267,7 @@ list Subfile::create_incremental(TarSegmentStore *tss, db->StoreObject(ref, block_csum, analyzed_len, block_age); if (analyzed_len >= 16384) store_block_signatures(ref, new_block_summary); + ref.set_range(0, analyzed_len, true); refs.push_back(ref); delete o; return refs; -- 2.20.1