From: Justin Tobler Date: Mon, 15 Dec 2025 16:26:36 GMT Subject: Re: [PATCH v2 2/7] strbuf: split out logic to humanise byte values Message-ID: In-Reply-To: On 25/12/15 06:33AM, Patrick Steinhardt wrote: > On Fri, Dec 12, 2025 at 04:36:39PM -0600, Justin Tobler wrote: > > All branches use `xstrfmt()` with strings that are essentially > constants, except for the translation part. So isn't it possible to drop > all these allocations and have the function return a `const char *` > instead? Ya, that would indeed be better. Will fix. > > diff --git a/strbuf.h b/strbuf.h > > index a580ac6084..a5e3ab0cb4 100644 > > --- a/strbuf.h > > +++ b/strbuf.h > > @@ -367,6 +367,15 @@ void strbuf_addbuf_percentquote(struct strbuf *dst, const struct strbuf *src); > > */ > > void strbuf_add_percentencode(struct strbuf *dst, const char *src, int flags); > > > > +#define STRBUF_HUMANISE_RATE 1 << 0 > > I think nowadays it's a bit more common to use an enum, and I think we > should also document what the flag does: > > enum strbuf_humanise_flags { > /* > * Frobnicate the string. > */ > STRBUF_HUMANISE_RATE = (1 << 0), > }; Will do. -Justin