[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 | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
Comments
Giuliano Procida <gprocida@google.com> a écrit:
> 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>
Applied to master, thanks!
[...]
Cheers,
@@ -1776,11 +1776,7 @@ 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(), ""));
if (!ctxt.get_corpus_group())
ctxt.clear_per_corpus_data();
@@ -1834,11 +1830,7 @@ 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(), ""));
if (!ctxt.get_corpus_group())
ctxt.clear_per_corpus_data();