Re: [PATCH] advice: refactor advise API
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 11, 2020, 06:08 UTC
- Message-ID
- <xmqqa75py7u8.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <CACg5j26RAEdABySzpDEYmo4m+HDPn9jNDP087d3K9gCro4m-Sg@mail.gmail.com>
Heba Waly <heba.waly@gmail.com> writes:
Show 14 quoted lines
> On Tue, Feb 11, 2020 at 11:46 AM Junio C Hamano <gitster@pobox.com> wrote: >> >> >> As I outlined in [1], I think the over-simplified >> "advise_ng(<advise.key>, _(<message>), ...)" would be too limited >> to replace the current users, without a pair of helper functions, >> one to just check for the guarding advise.key, and the other to >> unconditionally show the message (i.e. the latter is what the >> current advise() is). >> > > I agree with adding the first helper, specially after Peff's comments, > but I don't see why we would keep the current advise() which > unconditionally shows the message...
Look again at the message you referenced in your message that started this round, and read its comment:
if (advise_ng_enabled("frotz")) {
char *result = expensive_computation(...); /*
* advise_ng("frotz", _("message %s about frotz", result));
* is fine as well, but slightly less efficient as
* it would involve another call to *_enabled(), so use
* the unconditional form of the call
*/
advise_ng_raw(_("message %s about frotz", result));free(result); }