diff mbox series

[v2,3/7] index-pack: remove redundant parameter

Message ID f01f069a080d705ddb52e2353fa303b979a3cb78.1571343096.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. 17, 2019, 8:17 p.m. UTC
find_{ref,ofs}_delta_{,children} take an enum object_type parameter, but
the object type is already present in the name of the function. Remove
that parameter from these functions.

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

Comments

Josh Steadmon Feb. 28, 2020, 12:04 a.m. UTC | #1
On 2019.10.17 13:17, Jonathan Tan wrote:
> find_{ref,ofs}_delta_{,children} take an enum object_type parameter, but
> the object type is already present in the name of the function. Remove
> that parameter from these functions.
> 
> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
> ---
>  builtin/index-pack.c | 26 ++++++++++++--------------
>  1 file changed, 12 insertions(+), 14 deletions(-)
> 
> diff --git a/builtin/index-pack.c b/builtin/index-pack.c
> index df6b3b8cf6..296804230c 100644
> --- a/builtin/index-pack.c
> +++ b/builtin/index-pack.c
> @@ -614,7 +614,7 @@ static int compare_ofs_delta_bases(off_t offset1, off_t offset2,
>  	       0;
>  }
>  
> -static int find_ofs_delta(const off_t offset, enum object_type type)
> +static int find_ofs_delta(const off_t offset)
>  {
>  	int first = 0, last = nr_ofs_deltas;
>  
> @@ -624,7 +624,8 @@ static int find_ofs_delta(const off_t offset, enum object_type type)
>  		int cmp;
>  
>  		cmp = compare_ofs_delta_bases(offset, delta->offset,
> -					      type, objects[delta->obj_no].type);
> +					      OBJ_OFS_DELTA,
> +					      objects[delta->obj_no].type);
>  		if (!cmp)
>  			return next;
>  		if (cmp < 0) {

It looks like compare_ofs_delta_bases() could be similarly cleaned up
here? This seems to be the only caller.


> @@ -668,7 +668,7 @@ static int compare_ref_delta_bases(const struct object_id *oid1,
>  	return oidcmp(oid1, oid2);
>  }
>  
> -static int find_ref_delta(const struct object_id *oid, enum object_type type)
> +static int find_ref_delta(const struct object_id *oid)
>  {
>  	int first = 0, last = nr_ref_deltas;
>  
> @@ -678,7 +678,8 @@ static int find_ref_delta(const struct object_id *oid, enum object_type type)
>  		int cmp;
>  
>  		cmp = compare_ref_delta_bases(oid, &delta->oid,
> -					      type, objects[delta->obj_no].type);
> +					      OBJ_REF_DELTA,
> +					      objects[delta->obj_no].type);
>  		if (!cmp)
>  			return next;
>  		if (cmp < 0) {

And same with compare_ref_delta_bases here.


> @@ -691,10 +692,9 @@ static int find_ref_delta(const struct object_id *oid, enum object_type type)
>  }
>  
>  static void find_ref_delta_children(const struct object_id *oid,
> -				    int *first_index, int *last_index,
> -				    enum object_type type)
> +				    int *first_index, int *last_index)
>  {
> -	int first = find_ref_delta(oid, type);
> +	int first = find_ref_delta(oid);
>  	int last = first;
>  	int end = nr_ref_deltas - 1;
>  
> @@ -982,12 +982,10 @@ static struct base_data *find_unresolved_deltas_1(struct base_data *base,
>  {
>  	if (base->ref_last == -1 && base->ofs_last == -1) {
>  		find_ref_delta_children(&base->obj->idx.oid,
> -					&base->ref_first, &base->ref_last,
> -					OBJ_REF_DELTA);
> +					&base->ref_first, &base->ref_last);
>  
>  		find_ofs_delta_children(base->obj->idx.offset,
> -					&base->ofs_first, &base->ofs_last,
> -					OBJ_OFS_DELTA);
> +					&base->ofs_first, &base->ofs_last);
>  
>  		if (base->ref_last == -1 && base->ofs_last == -1) {
>  			free(base->data);
> -- 
> 2.23.0.866.gb869b98d4c-goog
>
Jonathan Tan March 10, 2020, 9:29 p.m. UTC | #2
> It looks like compare_ofs_delta_bases() could be similarly cleaned up
> here? This seems to be the only caller.

[snip]

> And same with compare_ref_delta_bases here.

That's true, although I didn't need these cleanups for the rest of my patches,
so I think it's better to defer them to reduce the overall size of the
patch.
diff mbox series

Patch

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index df6b3b8cf6..296804230c 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -614,7 +614,7 @@  static int compare_ofs_delta_bases(off_t offset1, off_t offset2,
 	       0;
 }
 
-static int find_ofs_delta(const off_t offset, enum object_type type)
+static int find_ofs_delta(const off_t offset)
 {
 	int first = 0, last = nr_ofs_deltas;
 
@@ -624,7 +624,8 @@  static int find_ofs_delta(const off_t offset, enum object_type type)
 		int cmp;
 
 		cmp = compare_ofs_delta_bases(offset, delta->offset,
-					      type, objects[delta->obj_no].type);
+					      OBJ_OFS_DELTA,
+					      objects[delta->obj_no].type);
 		if (!cmp)
 			return next;
 		if (cmp < 0) {
@@ -637,10 +638,9 @@  static int find_ofs_delta(const off_t offset, enum object_type type)
 }
 
 static void find_ofs_delta_children(off_t offset,
-				    int *first_index, int *last_index,
-				    enum object_type type)
+				    int *first_index, int *last_index)
 {
-	int first = find_ofs_delta(offset, type);
+	int first = find_ofs_delta(offset);
 	int last = first;
 	int end = nr_ofs_deltas - 1;
 
@@ -668,7 +668,7 @@  static int compare_ref_delta_bases(const struct object_id *oid1,
 	return oidcmp(oid1, oid2);
 }
 
-static int find_ref_delta(const struct object_id *oid, enum object_type type)
+static int find_ref_delta(const struct object_id *oid)
 {
 	int first = 0, last = nr_ref_deltas;
 
@@ -678,7 +678,8 @@  static int find_ref_delta(const struct object_id *oid, enum object_type type)
 		int cmp;
 
 		cmp = compare_ref_delta_bases(oid, &delta->oid,
-					      type, objects[delta->obj_no].type);
+					      OBJ_REF_DELTA,
+					      objects[delta->obj_no].type);
 		if (!cmp)
 			return next;
 		if (cmp < 0) {
@@ -691,10 +692,9 @@  static int find_ref_delta(const struct object_id *oid, enum object_type type)
 }
 
 static void find_ref_delta_children(const struct object_id *oid,
-				    int *first_index, int *last_index,
-				    enum object_type type)
+				    int *first_index, int *last_index)
 {
-	int first = find_ref_delta(oid, type);
+	int first = find_ref_delta(oid);
 	int last = first;
 	int end = nr_ref_deltas - 1;
 
@@ -982,12 +982,10 @@  static struct base_data *find_unresolved_deltas_1(struct base_data *base,
 {
 	if (base->ref_last == -1 && base->ofs_last == -1) {
 		find_ref_delta_children(&base->obj->idx.oid,
-					&base->ref_first, &base->ref_last,
-					OBJ_REF_DELTA);
+					&base->ref_first, &base->ref_last);
 
 		find_ofs_delta_children(base->obj->idx.offset,
-					&base->ofs_first, &base->ofs_last,
-					OBJ_OFS_DELTA);
+					&base->ofs_first, &base->ofs_last);
 
 		if (base->ref_last == -1 && base->ofs_last == -1) {
 			free(base->data);