summaryrefslogtreecommitdiff
path: root/gcc/stringpool.c
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2017-07-31 14:43:24 +0200
committerMartin Jambor <mjambor@suse.cz>2017-07-31 14:43:24 +0200
commitb32f12dece884f1fa0f04c643a77105aff6ce8bc (patch)
treecdab5f10806561fc198f907299b0e55eb5701ef0 /gcc/stringpool.c
parent166bec868d991fdf71f9a66f994e5977fcab4aa2 (diff)
parenta168a775e93ec31ae743ad282d8e60fa1c116891 (diff)
downloadgcc-gcn.tar.gz
Merge branch 'master' into gcngcn
Diffstat (limited to 'gcc/stringpool.c')
-rw-r--r--gcc/stringpool.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/gcc/stringpool.c b/gcc/stringpool.c
index 689327548e3..7aa4e8638d7 100644
--- a/gcc/stringpool.c
+++ b/gcc/stringpool.c
@@ -30,18 +30,6 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
-/* The "" allocated string. */
-const char empty_string[] = "";
-
-/* Character strings, each containing a single decimal digit.
- Written this way to save space. */
-static const char digit_vector[] = {
- '0', 0, '1', 0, '2', 0, '3', 0, '4', 0,
- '5', 0, '6', 0, '7', 0, '8', 0, '9', 0
-};
-
-#define digit_string(d) (digit_vector + ((d) * 2))
-
struct ht *ident_hash;
static hashnode alloc_node (cpp_hash_table *);
@@ -82,19 +70,16 @@ alloc_node (cpp_hash_table *table ATTRIBUTE_UNUSED)
const char *
ggc_alloc_string (const char *contents, int length MEM_STAT_DECL)
{
- char *result;
-
if (length == -1)
length = strlen (contents);
- if (length == 0)
- return empty_string;
- if (length == 1 && ISDIGIT (contents[0]))
- return digit_string (contents[0] - '0');
+ if (!length)
+ return "";
- result = (char *) ggc_internal_cleared_alloc (length + 1 PASS_MEM_STAT);
+ char *result = (char *) ggc_alloc_atomic (length + 1);
memcpy (result, contents, length);
result[length] = '\0';
+
return (const char *) result;
}