[v2,3/3] abg-reader: create a fresh corpus object per corpus
Commit Message
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>
---
src/abg-reader.cc | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
@@ -1889,16 +1889,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();
@@ -1952,16 +1948,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();