From: "René Scharfe." <l.s.r@web.de>
To: 胡哲宁 <adlternative@gmail.com>
Cc: "阿德烈 via GitGitGadget" <gitgitgadget@gmail.com>,
"Git List" <git@vger.kernel.org>,
"Junio C Hamano" <gitster@pobox.com>,
"Stefan Beller" <sbeller@google.com>
Subject: Re: [PATCH v2] alloc.h|c: migrate alloc_states to mem-pool
Date: Tue, 2 Feb 2021 17:36:00 +0100 [thread overview]
Message-ID: <f10273ef-3d71-5220-9985-1a4fa2c84cd3@web.de> (raw)
In-Reply-To: <CAOLTT8Rf0vjB1+RuChbVPgf=YDif4B1mnro2MEF6E8+uGXM24Q@mail.gmail.com>
Am 02.02.21 um 14:12 schrieb 胡哲宁:
> To René Scharfe:
>>> - struct alloc_state *blob_state;
>>> - struct alloc_state *tree_state;
>>> - struct alloc_state *commit_state;
>>> - struct alloc_state *tag_state;
>>> - struct alloc_state *object_state;
>>> + struct mem_pool *blob_pool;
>>> + struct mem_pool *tree_pool;
>>> + struct mem_pool *commit_pool;
>>> + struct mem_pool *tag_pool;
>>> + struct mem_pool *object_pool;
>>
>> Why have pointers here instead of the structs themselves? It's not like
>> a struct parsed_object_pool is of much use without them, right?
>>
>> The same question applies to the original code as well, of course.
> Here I may have some questions: why use `struct mem_pool` instead of
> using `struct mem_pool *`?
> I hope you can answer my doubts, thank you!
If struct parsed_object_pool contains pointers to five instances of
struct alloc_state or struct mem_pool then you have to allocate and
eventually release those instances explicitly. Your patch introduced
mem_pool_new() for the allocation part.
If the five instances are embedded in struct parsed_object_pool then
you don't need to do that.
The indirection added by allocating explicitly and using pointers
would be beneficial if some of five instances were optional, as you
could skip their allocation and save some memory -- but you need
them all to get a usable struct parsed_object_pool.
René
next prev parent reply other threads:[~2021-02-02 16:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-30 12:59 [PATCH] alloc.h|c: migrate alloc_states to mem-pool 阿德烈 via GitGitGadget
2021-02-01 10:39 ` [PATCH v2] " 阿德烈 via GitGitGadget
2021-02-01 17:55 ` René Scharfe
2021-02-02 13:12 ` 胡哲宁
2021-02-02 16:36 ` René Scharfe. [this message]
2021-02-01 17:56 ` Junio C Hamano
2021-02-02 13:06 ` 胡哲宁
2021-02-04 10:33 ` [PATCH v3] " 阿德烈 via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f10273ef-3d71-5220-9985-1a4fa2c84cd3@web.de \
--to=l.s.r@web.de \
--cc=adlternative@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).