Re: [PATCH] strbuf: add and use strbuf_insertstr()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Feb 8, 2020 at 2:57 PM René Scharfe <l.s.r@xxxxxx> wrote:
> Add a function for inserting a C string into a strbuf.  Use it
> throughout the source to get rid of magic string length constants and
> explicit strlen() calls.
>
> Like strbuf_addstr(), implement it as an inline function to avoid the
> implicit strlen() calls to cause runtime overhead.
>
> Signed-off-by: René Scharfe <l.s.r@xxxxxx>
> ---
> diff --git a/notes-utils.c b/notes-utils.c
> @@ -52,7 +52,7 @@ void commit_notes(struct repository *r, struct notes_tree *t, const char *msg)
> -       strbuf_insert(&buf, 0, "notes: ", 7); /* commit message starts at index 7 */
> +       strbuf_insertstr(&buf, 0, "notes: "); /* commit message starts at index 7 */

Is there a reason to retain the comment which talks about magic number 7?



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux