On 12/20/2017 10:45 AM, Jakub Jelinek wrote:
On Wed, Dec 20, 2017 at 10:35:44AM -0700, Martin Sebor wrote:
On 10/27/2017 07:17 AM, Martin Liška wrote:
Hello.

It's improvement that I consider still useful even though we're not
going to use
it for profiled bootstrap.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

For what it's worth, although it looks correct as is, I think
the code in the patch would be clearer and less prone to off
by-1 errors, while at the same time equally as efficient, if
it were written in terms of strcpy and strcat:

  char *b = XNEWVEC (char,
                     2 + strlen (pwd)
                     + strlen (profile_data_prefix));

  strcpy (b, profile_data_prefix);
  strcat (b, "/");
  strcat (b, pwd);

I disagree.

Of course you do.

 One thing is that GCC attempts to optimize even bad code;
in many cases just can't as soon as there is some call in between etc.,
the other is that we just shouldn't give bad examples.
When you know the sizes, we shouldn't be lazy and rely on compiler to figure
out what we should have written.

It's my turn to disagree now.  We most certainly should be lazy
and rely on our tools and high-level abstractions to do the work
for us.  That's what they're for.

Though on this case we have a nice
function for all of that,
  char *b = concat (profile_data_prefix, "/", pwd, NULL);

Even better (unless this is being lazy ;-)

Martin

Reply via email to