copy source stringmap as necessary in stringmap_merge
This commit is contained in:
parent
0970b15034
commit
797bdb7224
1 changed files with 5 additions and 5 deletions
|
|
@ -81,11 +81,8 @@ static void *combine_entries(HHashSet *workset, void *dst, const void *src)
|
||||||
|
|
||||||
// add the mappings of src to dst, marking conflicts and adding the conflicting
|
// add the mappings of src to dst, marking conflicts and adding the conflicting
|
||||||
// values to workset.
|
// values to workset.
|
||||||
// note: reuses parts of src to build dst!
|
|
||||||
static void stringmap_merge(HHashSet *workset, HStringMap *dst, HStringMap *src)
|
static void stringmap_merge(HHashSet *workset, HStringMap *dst, HStringMap *src)
|
||||||
{
|
{
|
||||||
assert(src->arena == dst->arena);
|
|
||||||
|
|
||||||
if(src->epsilon_branch) {
|
if(src->epsilon_branch) {
|
||||||
if(dst->epsilon_branch)
|
if(dst->epsilon_branch)
|
||||||
dst->epsilon_branch =
|
dst->epsilon_branch =
|
||||||
|
|
@ -120,14 +117,17 @@ static void stringmap_merge(HHashSet *workset, HStringMap *dst, HStringMap *src)
|
||||||
|
|
||||||
if(src_) {
|
if(src_) {
|
||||||
HStringMap *dst_ = h_hashtable_get(dst->char_branches, (void *)c);
|
HStringMap *dst_ = h_hashtable_get(dst->char_branches, (void *)c);
|
||||||
if(dst_)
|
if(dst_) {
|
||||||
stringmap_merge(workset, dst_, src_);
|
stringmap_merge(workset, dst_, src_);
|
||||||
else
|
} else {
|
||||||
|
if(src_->arena != dst->arena)
|
||||||
|
src_ = h_stringmap_copy(dst->arena, src_);
|
||||||
h_hashtable_put(dst->char_branches, (void *)c, src_);
|
h_hashtable_put(dst->char_branches, (void *)c, src_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Generate entries for the productions of A in the given table row. */
|
/* Generate entries for the productions of A in the given table row. */
|
||||||
static int fill_table_row(size_t kmax, HCFGrammar *g, HStringMap *row,
|
static int fill_table_row(size_t kmax, HCFGrammar *g, HStringMap *row,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue