diff mbox series

[5/6] index-pack: make resolve_delta() assume base data

Message ID 6fcda102acd550818536c69c41c270a8058050a7.1570663470.git.jonathantanmy@google.com (mailing list archive)
State New, archived
Headers show
Series Better threaded delta resolution in index-pack | expand

Commit Message

Jonathan Tan Oct. 9, 2019, 11:44 p.m. UTC
A subsequent commit will make the quantum of work smaller, necessitating
more locking. This commit allows resolve_delta() to be called outside
the lock.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
---
 builtin/index-pack.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Jeff King Oct. 17, 2019, 6:32 a.m. UTC | #1
On Wed, Oct 09, 2019 at 04:44:21PM -0700, Jonathan Tan wrote:

> A subsequent commit will make the quantum of work smaller, necessitating
> more locking. This commit allows resolve_delta() to be called outside
> the lock.

OK, that makes sense, I think.

-Peff
diff mbox series

Patch

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 17997834ec..3908cd3115 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -926,7 +926,7 @@  static struct base_data *make_base(struct object_entry *obj,
 static struct base_data *resolve_delta(struct object_entry *delta_obj,
 				       struct base_data *base)
 {
-	void *base_data, *delta_data, *result_data;
+	void *delta_data, *result_data;
 	struct base_data *result;
 	unsigned long result_size;
 
@@ -941,8 +941,8 @@  static struct base_data *resolve_delta(struct object_entry *delta_obj,
 		obj_stat[i].base_object_no = j;
 	}
 	delta_data = get_data_from_pack(delta_obj);
-	base_data = get_base_data(base);
-	result_data = patch_delta(base_data, base->size,
+	assert(base->data);
+	result_data = patch_delta(base->data, base->size,
 				  delta_data, delta_obj->size, &result_size);
 	free(delta_data);
 	if (!result_data)
@@ -1000,6 +1000,7 @@  static struct base_data *find_unresolved_deltas_1(struct base_data *base,
 					   base->obj->real_type))
 			BUG("child->real_type != OBJ_REF_DELTA");
 
+		get_base_data(base);
 		result = resolve_delta(child, base);
 		if (base->ref_first == base->ref_last && base->ofs_last == -1)
 			free_base_data(base);
@@ -1014,6 +1015,7 @@  static struct base_data *find_unresolved_deltas_1(struct base_data *base,
 
 		assert(child->real_type == OBJ_OFS_DELTA);
 		child->real_type = base->obj->real_type;
+		get_base_data(base);
 		result = resolve_delta(child, base);
 		if (base->ofs_first == base->ofs_last)
 			free_base_data(base);