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

Re: [Annoyance] "git log .." thinks ".." is ambiguous

From
Junio C Hamano <gitster@pobox.com>
Date
May 3, 2011, 19:00 UTC
Message-ID
<7v7ha7ip81.fsf@alter.siamese.dyndns.org>
In-Reply-To
<86404CD9-6040-4083-912F-23F4C11F4ED2@gmail.com>
Joshua Juran <jjuran@gmail.com> writes:
Show 6 quoted lines
> My recollection is that Metrowerks C will statically allocate read-
> write storage (duplicating the read-only copy of the string) and copy
> the string into it at runtime.  It only copies the string once, which
> is ensured by checking an internally generated flag (also statically
> allocated) every time the scope containing the declaration is
> executed.  This is the pessimization I speak of.

That's a stupid compiler, isn't it? Doesn't it pay attention to the fact that the static char string in the function scope also says "const"?

A sane compiler would store { 'H' 'E' 'A' 'D' '\0' } five bytes in a data segment (preferrably ro), give it a label and turn its assignment to and comparison with "next" and "this" to a reference to that label address, and all can be resolved by the linker. Your suggestion will give a compiler an excuse to allocate an extra pointer variable to hold that address in addition to that, espcially if you do not say const twice.

Of course the extra pointer could be optimized away if you follow the data and if the compiler does so we would get the same code.

Previous: Michael J GruberNext: John Szakmeister
Message 18 of 19 in “[Annoyance] "git log .." thinks ".." is ambiguous”
  1. Junio C HamanoMay 2, 2011
  2. Jeff KingMay 2, 2011
  3. Jeff KingMay 2, 2011
  4. Junio C HamanoMay 2, 2011
  5. Jeff KingMay 2, 2011
  6. specifying ranges: we did not mean to make ".." an empty setJunio C Hamano, May 2, 2011
  7. Jeff KingMay 2, 2011
  8. Junio C HamanoMay 2, 2011
  9. Michael J GruberMay 3, 2011
  10. Junio C HamanoMay 3, 2011
  11. Michael J GruberMay 4, 2011
  12. Junio C HamanoMay 4, 2011
  13. Junio C HamanoMay 4, 2011
  14. Joshua JuranMay 3, 2011
  15. Michael J GruberMay 3, 2011
  16. Joshua JuranMay 3, 2011
  17. Michael J GruberMay 3, 2011
  18. Junio C HamanoMay 3, 2011
  19. John SzakmeisterMay 3, 2011

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.