+2014-11-25 Ilya Tocar <ilya.tocar@intel.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ * gcc.c (handle_foffload_option): Remove unnecessary calls to strchr,
+ strlen, strncpy.
+ * lto-wrapper.c (append_offload_options): Likewise.
+
2014-11-25 Eric Botcazou <ebotcazou@adacore.com>
* config/rs6000/rs6000.c (rs6000_call_aix): For the AIX ABI, do not
{
next = strchr (cur, ',');
if (next == NULL)
- next = strchr (cur, '\0');
+ next = end;
next = (next > end) ? end : next;
target = XNEWVEC (char, next - cur + 1);
- strncpy (target, cur, next - cur);
+ memcpy (target, cur, next - cur);
target[next - cur] = '\0';
/* If 'disable' is passed to the option, stop parsing the option and clean
if (n == NULL)
n = strchr (c, '\0');
- if (strlen (target) == (size_t) (n - c)
- && strncmp (target, c, n - c) == 0)
+ if (next - cur == n - c && strncmp (target, c, n - c) == 0)
break;
c = *n ? n + 1 : NULL;
target);
if (!offload_targets)
- offload_targets = xstrdup (target);
+ {
+ offload_targets = target;
+ target = NULL;
+ }
else
{
/* Check that the target hasn't already presented in the list. */
if (n == NULL)
n = strchr (c, '\0');
- if (strlen (target) == (size_t) (n - c)
- && strncmp (c, target, n - c) == 0)
+ if (next - cur == n - c && strncmp (c, target, n - c) == 0)
break;
c = n + 1;
/* If duplicate is not found, append the target to the list. */
if (c > n)
{
+ size_t offload_targets_len = strlen (offload_targets);
offload_targets
= XRESIZEVEC (char, offload_targets,
- strlen (offload_targets) + strlen (target) + 2);
- if (strlen (offload_targets) != 0)
- strcat (offload_targets, ":");
- strcat (offload_targets, target);
+ offload_targets_len + next - cur + 2);
+ if (offload_targets_len)
+ offload_targets[offload_targets_len++] = ':';
+ memcpy (offload_targets + offload_targets_len, target, next - cur);
}
}