summaryrefslogtreecommitdiff
path: root/gcc/gcc.c
diff options
context:
space:
mode:
authortocarip <tocarip@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-25 13:56:03 +0000
committertocarip <tocarip@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-25 13:56:03 +0000
commit6a892749dc43e49f8e2364db104e732e83a1fc2e (patch)
tree9ecd455af2d5a192d1d2e62f558b237a9f88e62d /gcc/gcc.c
parent18adeccd008553a7634794c9b8a8209619742902 (diff)
downloadgcc-6a892749dc43e49f8e2364db104e732e83a1fc2e.tar.gz
Remove unnecessary calls to strchr.
gcc/ * gcc.c (handle_foffload_option): Remove unnecessary calls to strchr, strlen, strncpy. * lto-wrapper.c (append_offload_options): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218044 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r--gcc/gcc.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index c6d1baf58df..b730ba53d7e 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -3384,11 +3384,11 @@ handle_foffload_option (const char *arg)
{
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
@@ -3408,8 +3408,7 @@ handle_foffload_option (const char *arg)
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;
@@ -3420,7 +3419,10 @@ handle_foffload_option (const char *arg)
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. */
@@ -3431,8 +3433,7 @@ handle_foffload_option (const char *arg)
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;
@@ -3442,12 +3443,13 @@ handle_foffload_option (const char *arg)
/* 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);
}
}