aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/tree-streamer.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/tree-streamer.c')
-rw-r--r--gcc-4.9/gcc/tree-streamer.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/gcc-4.9/gcc/tree-streamer.c b/gcc-4.9/gcc/tree-streamer.c
index af9461e77..517bf77f6 100644
--- a/gcc-4.9/gcc/tree-streamer.c
+++ b/gcc-4.9/gcc/tree-streamer.c
@@ -101,20 +101,19 @@ static void
streamer_tree_cache_add_to_node_array (struct streamer_tree_cache_d *cache,
unsigned ix, tree t, hashval_t hash)
{
- /* Make sure we're either replacing an old element or
- appending consecutively. */
- gcc_assert (ix <= cache->nodes.length ());
-
- if (ix == cache->nodes.length ())
+ /* We're either replacing an old element or appending consecutively. */
+ if (cache->nodes.exists ())
{
- cache->nodes.safe_push (t);
- if (cache->hashes.exists ())
- cache->hashes.safe_push (hash);
+ if (cache->nodes.length () == ix)
+ cache->nodes.safe_push (t);
+ else
+ cache->nodes[ix] = t;
}
- else
+ if (cache->hashes.exists ())
{
- cache->nodes[ix] = t;
- if (cache->hashes.exists ())
+ if (cache->hashes.length () == ix)
+ cache->hashes.safe_push (hash);
+ else
cache->hashes[ix] = hash;
}
}
@@ -146,7 +145,7 @@ streamer_tree_cache_insert_1 (struct streamer_tree_cache_d *cache,
{
/* Determine the next slot to use in the cache. */
if (insert_at_next_slot_p)
- ix = cache->nodes.length ();
+ ix = cache->next_idx++;
else
ix = *ix_p;
*slot = ix;
@@ -211,7 +210,7 @@ void
streamer_tree_cache_append (struct streamer_tree_cache_d *cache,
tree t, hashval_t hash)
{
- unsigned ix = cache->nodes.length ();
+ unsigned ix = cache->next_idx++;
if (!cache->node_map)
streamer_tree_cache_add_to_node_array (cache, ix, t, hash);
else
@@ -326,7 +325,7 @@ preload_common_nodes (struct streamer_tree_cache_d *cache)
/* Create a cache of pickled nodes. */
struct streamer_tree_cache_d *
-streamer_tree_cache_create (bool with_hashes, bool with_map)
+streamer_tree_cache_create (bool with_hashes, bool with_map, bool with_vec)
{
struct streamer_tree_cache_d *cache;
@@ -334,7 +333,9 @@ streamer_tree_cache_create (bool with_hashes, bool with_map)
if (with_map)
cache->node_map = new pointer_map<unsigned>;
- cache->nodes.create (165);
+ cache->next_idx = 0;
+ if (with_vec)
+ cache->nodes.create (165);
if (with_hashes)
cache->hashes.create (165);