Re: [Annoyance] "git log .." thinks ".." is ambiguous
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:51:09
Joshua Juran [off-list ref] writes:
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.