Re: [PATCH v3 05/11] http.c: Don't store destination name in request structures
- From
Tay Ray Chuan <rctay89@gmail.com>
- Date
- Apr 18, 2010, 03:36 UTC
- Message-ID
- <20100418113619.00007e39@unknown>
- In-Reply-To
- <1271534864-31944-5-git-send-email-spearce@spearce.org>
Hi,
On Sat, 17 Apr 2010 13:07:38 -0700 "Shawn O. Pearce" <spearce@spearce.org> wrote:
Show 10 quoted lines
> The destination name within the object store is easily computed > on demand, reusing a static buffer held by sha1_file.c. We don't > need to copy the entire path into the request structure for safe > keeping, when it can be easily reformatted after the download has > been completed. > > This reduces the size of the per-request structure, and removes > yet another PATH_MAX based limit. > > Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
now that there's a single user of char *filename, we might as well do away with it.
PS. I think having the below as a separate patch is better than squashing it in, as it might be detrimental to patch #05's readability in the latter case.
-->8-- From: Tay Ray Chuan <rctay89@gmail.com> Subject: [PATCH] http.c::new_http_pack_request: do away with the temp variable filename
Now that the temporary variable char *filename is only used in one place, do away with it and just call sha1_pack_name() directly.
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
diff --git a/http.c b/http.c index c75eb95..110cff9 100644 --- a/http.c +++ b/http.c @@ -1027,7 +1027,6 @@ int finish_http_pack_request(struct http_pack_request *preq) struct http_pack_request *new_http_pack_request( struct packed_git *target, const char *base_url) { - char *filename; long prev_posn = 0; char range[RANGE_HEADER_SIZE]; struct strbuf buf = STRBUF_INIT; @@ -1042,8 +1041,8 @@ struct http_pack_request *new_http_pack_request( sha1_to_hex(target->sha1)); preq->url = strbuf_detach(&buf, NULL); - filename = sha1_pack_name(target->sha1); - snprintf(preq->tmpfile, sizeof(preq->tmpfile), "%s.temp", filename); + snprintf(preq->tmpfile, sizeof(preq->tmpfile), "%s.temp", + sha1_pack_name(target->sha1)); preq->packfile = fopen(preq->tmpfile, "a"); if (!preq->packfile) { error("Unable to open local file %s for pack", --
-- Cheers, Ray Chuan