streaming.c: remove {open,close,read}_method_decl() macros
Remove the {open,close,read}_method_decl() macros added in 46bf043807c (streaming: a new API to read from the object store, 2011-05-11) in favor of inlining the definition of the arguments of these functions. Since we'll end up using them via the "{open,close,read}_istream_fn" types we don't gain anything in the way of compiler checking by using these macros, and as of preceding commits we no longer need to declare these argument lists twice. So declaring them at a distance just serves to make the code less readable. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
May 5, 2021 at 14:33 UTC
bc062ad001f31a466d9aa3987005e34b3d9bbff4
1 file changed
+22
-25
streaming.c
+22
-25
@@ -21,20 +21,6 @@ struct stream_vtbl {
21
read_istream_fn read;
22
};
23
24
-#define open_method_decl(name) \
25
- int open_istream_ ##name \
26
- (struct git_istream *st, struct repository *r, \
27
- struct object_info *oi, const struct object_id *oid, \
28
- enum object_type *type)
29
-
30
-#define close_method_decl(name) \
31
- int close_istream_ ##name \
32
- (struct git_istream *st)
33
-
34
-#define read_method_decl(name) \
35
- ssize_t read_istream_ ##name \
36
- (struct git_istream *st, char *buf, size_t sz)
37
-
24
#define FILTER_BUFFER (1024*16)
25
26
struct filtered_istream {
@@ -95,13 +81,14 @@ static void close_deflated_stream(struct git_istream *st)
81
*
82
*****************************************************************/
83
98
-static close_method_decl(filtered)
84
+static int close_istream_filtered(struct git_istream *st)
85
{
86
free_stream_filter(st->u.filtered.filter);
87
return close_istream(st->u.filtered.upstream);
88
}
89
104
-static read_method_decl(filtered)
90
+static ssize_t read_istream_filtered(struct git_istream *st, char *buf,
91
+ size_t sz)
92
{
93
struct filtered_istream *fs = &(st->u.filtered);
94
size_t filled = 0;
@@ -187,7 +174,7 @@ static struct git_istream *attach_stream_filter(struct git_istream *st,
174
*
175
*****************************************************************/
176
190
-static read_method_decl(loose)
177
+static ssize_t read_istream_loose(struct git_istream *st, char *buf, size_t sz)
178
{
179
size_t total_read = 0;
180
@@ -232,7 +219,7 @@ static read_method_decl(loose)
219
return total_read;
220
}
221
235
-static close_method_decl(loose)
222
+static int close_istream_loose(struct git_istream *st)
223
{
224
close_deflated_stream(st);
225
munmap(st->u.loose.mapped, st->u.loose.mapsize);
@@ -244,7 +231,10 @@ static struct stream_vtbl loose_vtbl = {
231
read_istream_loose,
232
};
233
247
-static open_method_decl(loose)
234
+static int open_istream_loose(struct git_istream *st, struct repository *r,
235
+ struct object_info *oi,
236
+ const struct object_id *oid,
237
+ enum object_type *type)
238
{
239
st->u.loose.mapped = map_loose_object(r, oid, &st->u.loose.mapsize);
240
if (!st->u.loose.mapped)
@@ -275,7 +265,8 @@ static open_method_decl(loose)
265
*
266
*****************************************************************/
267
278
-static read_method_decl(pack_non_delta)
268
+static ssize_t read_istream_pack_non_delta(struct git_istream *st, char *buf,
269
+ size_t sz)
270
{
271
size_t total_read = 0;
272
@@ -333,7 +324,7 @@ static read_method_decl(pack_non_delta)
324
return total_read;
325
}
326
336
-static close_method_decl(pack_non_delta)
327
+static int close_istream_pack_non_delta(struct git_istream *st)
328
{
329
close_deflated_stream(st);
330
return 0;
@@ -344,7 +335,11 @@ static struct stream_vtbl pack_non_delta_vtbl = {
335
read_istream_pack_non_delta,
336
};
337
347
-static open_method_decl(pack_non_delta)
338
+static int open_istream_pack_non_delta(struct git_istream *st,
339
+ struct repository *r,
340
+ struct object_info *oi,
341
+ const struct object_id *oid,
342
+ enum object_type *type)
343
{
344
struct pack_window *window;
345
enum object_type in_pack_type;
@@ -379,13 +374,13 @@ static open_method_decl(pack_non_delta)
374
*
375
*****************************************************************/
376
382
-static close_method_decl(incore)
377
+static int close_istream_incore(struct git_istream *st)
378
{
379
free(st->u.incore.buf);
380
return 0;
381
}
382
388
-static read_method_decl(incore)
383
+static ssize_t read_istream_incore(struct git_istream *st, char *buf, size_t sz)
384
{
385
size_t read_size = sz;
386
size_t remainder = st->size - st->u.incore.read_ptr;
@@ -404,7 +399,9 @@ static struct stream_vtbl incore_vtbl = {
399
read_istream_incore,
400
};
401
407
-static open_method_decl(incore)
402
+static int open_istream_incore(struct git_istream *st, struct repository *r,
403
+ struct object_info *oi, const struct object_id *oid,
404
+ enum object_type *type)
405
{
406
st->u.incore.buf = read_object_file_extended(r, oid, type, &st->size, 0);
407
st->u.incore.read_ptr = 0;