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

Re: [PATCH 4/3] Introduce 'convert_path_to_git()'

From
Junio C Hamano <gitster@pobox.com>
Date
May 16, 2009, 06:40 UTC
Message-ID
<7vy6sxpn2q.fsf@alter.siamese.dyndns.org>
In-Reply-To
<alpine.LFD.2.01.0905151156090.3343@localhost.localdomain>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 12 quoted lines
> +#ifdef FAST_UNALIGNED
> +	while (plen >= sizeof(unsigned long)) {
> +		unsigned long x = *(unsigned long *)path;
> +		if (x & (unsigned long) 0x8080808080808080ull)
> +			break;
> +		*(unsigned long *)result = x;
> +		path += sizeof(unsigned long);
> +		result += sizeof(unsigned long);
> +		plen -= sizeof(unsigned long);
> +		retval += sizeof(unsigned long);
> +	}
> +#endif

It somehow bothers me that the stride of this loop is protected from having different size of unsigned long from what the author of this function expected, but the literal constant used as the mask is not quite, which means that taken as a whole it does not work if your unsigned long is more than 8-bytes. No, I do not think it matters in practice, and I find it a neat trick to cast the unsigned long long literal down to unsigned long, but still it looks somewhat, eh, what would I say...

"Ugly" is not quite the word I am looking for. "My gut feels that there has to be a way to write this more cleanly, but I am frustrated that I cannot come up with one" might be the word...

Previous: Linus TorvaldsNext: Linus Torvalds
Message 10 of 13 in “dir.c: clean up handling of 'path' parameter in read_directory_recursive()”
  1. 1/3 dir.c: clean up handling of 'path' parameter in read_directory_recursive()Linus Torvalds, May 14, 2009
  2. 2/3 Add 'fill_directory()' helper function for directory traversalLinus Torvalds, May 14, 2009
  3. 3/3 read_directory(): infrastructure for pathname character set conversionLinus Torvalds, May 14, 2009
  4. Linus TorvaldsMay 14, 2009
  5. Johannes SchindelinMay 14, 2009
  6. Aaron CohenMay 14, 2009
  7. Linus TorvaldsMay 14, 2009
  8. Linus TorvaldsMay 14, 2009
  9. 4/3 Introduce 'convert_path_to_git()'Linus Torvalds, May 15, 2009
  10. Junio C HamanoMay 16, 2009
  11. Linus TorvaldsMay 16, 2009
  12. Jens KilianMay 19, 2009
  13. John KoleszarMay 19, 2009

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.