From: Quint Guvernator <quintus.public@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] general style: replaces memcmp() with proper starts_with()
Date: Wed, 12 Mar 2014 23:33:50 -0400 [thread overview]
Message-ID: <CALs4jVHTBH3wTAQsv8+jb15Do1_oy0pcThsDL8ssE7fgrx5NxA@mail.gmail.com> (raw)
In-Reply-To: <xmqqd2hrjb4d.fsf@gitster.dls.corp.google.com>
>From what I can gather, there seems to be opposition to specific
pieces of this patch.
The following area is clearly the most controversial:
> static inline int standard_header_field(const char *field, size_t len)
> {
> - return ((len == 4 && !memcmp(field, "tree ", 5)) ||
> - (len == 6 && !memcmp(field, "parent ", 7)) ||
> - (len == 6 && !memcmp(field, "author ", 7)) ||
> - (len == 9 && !memcmp(field, "committer ", 10)) ||
> - (len == 8 && !memcmp(field, "encoding ", 9)));
> + return ((len == 4 && starts_with(field, "tree ")) ||
> + (len == 6 && starts_with(field, "parent ")) ||
> + (len == 6 && starts_with(field, "author ")) ||
> + (len == 9 && starts_with(field, "committer ")) ||
> + (len == 8 && starts_with(field, "encoding ")));
I am happy to submit a version of this patch excluding this section
(and/or others), but it seems I've stumbled into a more fundamental
conversation about the place for helper functions in general (and
about refactoring skip_prefix()). I am working on this particular
change as a microproject, #14 on the list [1], and am not as familiar
with the conventions of the Git codebase as many of you on this list
are.
Junio said:
> The result after the conversion, however, still have the same magic
> numbers, but one less of them each. Doesn't it make it harder to
> later spot the patterns to come up with a better abstraction that
> does not rely on the magic number?
It is _not_ my goal to make the code harder to maintain down the road.
So, at this point, which hunks (if any) are worth patching?
Quint
[1]: http://git.github.io/SoC-2014-Microprojects.html
next prev parent reply other threads:[~2014-03-13 3:34 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-12 14:43 [PATCH] general style: replaces memcmp() with proper starts_with() Quint Guvernator
2014-03-12 17:56 ` Jeff King
2014-03-12 19:39 ` Junio C Hamano
2014-03-12 19:49 ` Jeff King
2014-03-12 20:08 ` Junio C Hamano
2014-03-12 21:14 ` Jeff King
2014-03-12 21:39 ` Jeff King
2014-03-12 22:06 ` Jeff King
2014-03-12 22:38 ` Junio C Hamano
2014-03-13 3:33 ` Quint Guvernator [this message]
2014-03-13 17:46 ` Junio C Hamano
2014-03-14 4:57 ` Jeff King
2014-03-14 14:51 ` Quint Guvernator
2014-03-14 16:56 ` Junio C Hamano
2014-03-12 20:51 ` René Scharfe
2014-03-12 21:16 ` David Kastrup
2014-03-12 21:45 ` René Scharfe
2014-03-12 20:52 ` David Kastrup
2014-03-12 22:37 ` Junio C Hamano
2014-03-13 6:27 ` David Kastrup
2014-03-13 17:47 ` Junio C Hamano
2014-03-13 17:55 ` Jeff King
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALs4jVHTBH3wTAQsv8+jb15Do1_oy0pcThsDL8ssE7fgrx5NxA@mail.gmail.com \
--to=quintus.public@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).