git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Refactoring hardcoded SHA-1 constants

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Apr 18, 2014, 22:40 UTC
Message-ID
<20140418224049.GA15516@google.com>
In-Reply-To
<20140418221841.GC57656@vauxhall.crustytoothpaste.net>
Hi,
brian m. carlson wrote:
> I'd like to introduce a set of preprocessor constants that we'd use
> instead of hard-coded 20s and 40s everywhere.

Lukewarm on that. It's hard to do consistently and unless they're named well it can be harder to know what something like BINARY_OBJECT_NAME_LENGTH means than plain '20' when first reading.

[...]
> I would also like to consider, as a third step, turning all of the
> unsigned char[20] uses into a struct containing unsigned char[20] as its
> only member, like libgit2 does.
That would be very welcome!

It's a nice way to steer people toward hashcmp using the type system, and it makes it possible to use a union to enforce alignment later if measurements show benefit.

Thanks, Jonathan

Previous: brian m. carlsonNext: Michael Haggerty
Message 2 of 6 in “Refactoring hardcoded SHA-1 constants”
  1. brian m. carlsonApr 18, 2014
  2. Jonathan NiederApr 18, 2014
  3. Michael HaggertyApr 19, 2014
  4. Duy NguyenApr 19, 2014
  5. Junio C HamanoApr 19, 2014
  6. Duy NguyenApr 19, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.