abg-reader: Create a fresh corpus object per corpus

Currently the XML reader reuses the same corpus object for all
corpora in a corpus group. This has an unwanted side-effect: any
abi-instr with the same path in different corpora will collide and
parts of the ABI will be lost.

Creating a new corpus object for every abi-corpus element seems like
the right thing to do. Testing with large ABIs containing many corpora
also shows a modest (~10%) abidiff speed improvement.

	* src/abg-reader.cc (read_corpus_from_input): Always create a
	fresh corpus object for each abi-corpus XML element.

Signed-off-by: Giuliano Procida <gprocida@google.com>
This commit is contained in:
Giuliano Procida 2021-05-27 09:53:05 +01:00 committed by Dodji Seketeli
parent 25bd77e31e
commit caf06d7e5c

View File

@ -1898,16 +1898,12 @@ read_corpus_from_input(read_context& ctxt)
BAD_CAST("abi-corpus")))
return nil;
if (!ctxt.get_corpus())
{
corpus_sptr c(new corpus(ctxt.get_environment(), ""));
ctxt.set_corpus(c);
ctxt.set_corpus(std::make_shared<corpus>(ctxt.get_environment(), ""));
#ifdef WITH_DEBUG_SELF_COMPARISON
if (ctxt.get_environment()->self_comparison_debug_is_on())
ctxt.get_environment()->
set_self_comparison_debug_input(ctxt.get_corpus());
if (ctxt.get_environment()->self_comparison_debug_is_on())
ctxt.get_environment()->
set_self_comparison_debug_input(ctxt.get_corpus());
#endif
}
if (!ctxt.get_corpus_group())
ctxt.clear_per_corpus_data();
@ -1961,16 +1957,12 @@ read_corpus_from_input(read_context& ctxt)
}
else
{
if (!ctxt.get_corpus())
{
corpus_sptr c(new corpus(ctxt.get_environment(), ""));
ctxt.set_corpus(c);
ctxt.set_corpus(std::make_shared<corpus>(ctxt.get_environment(), ""));
#ifdef WITH_DEBUG_SELF_COMPARISON
if (ctxt.get_environment()->self_comparison_debug_is_on())
ctxt.get_environment()->
set_self_comparison_debug_input(ctxt.get_corpus());
if (ctxt.get_environment()->self_comparison_debug_is_on())
ctxt.get_environment()->
set_self_comparison_debug_input(ctxt.get_corpus());
#endif
}
if (!ctxt.get_corpus_group())
ctxt.clear_per_corpus_data();